What is the body_class function equivalent

wordpress

#1

Hi Guys,

What is the equivalent of body_class function, Envato rejects themes that used body_class and WordPress itself using it in TwentySixteen built-in theme … What should we do?

The body_class prints the most important css classes in the whole project, [ classes like - admin-bar, logged-in, etc. ] those are very important classes to increase the body margins for logged-in users because of admin menu.

I looked for an equivalent function to print these classes but nothing, There’s only one function handles the main style.


#2

body_class on the body tag is a requirement here, you will be rejected for not using it, or using it incorrectly. Re-check your rejection.


#3

Reason from e-mail:

You should avoid and not to hardcode custom body_class().
Main reason for this is being able to remove the class when needed i.e. child themes.
What you can do - https://gist.github.com/kailoon/d4d22c9204909dff21eb


#4

We’re using it like all themes in header.php and inside body tag

<body <?php body_class($array_of_custom_classes); ?> >


#5

Exactly, so your rejection isn’t because you used the body_class function, it’s because you used it wrong. Use the function you’ve been given to filter your body classes, rather then adding an array directly to body_class.


#6

So calling it without $array_classes and add_filter outside in a separate function??

add_filter( 'body_class', 'function_custom_body_class' );


#7

Should we use post_class function like body_class??

Because we need to add an additional classes in every blog item inside the loop so add_filter won’t work here.


#8

Admittedly, I’ve never had this issue from a review, but the requirements seem to change day by day at the moment.

If you can do it on post_class with a filter without too much of a headache, it might be worth it, but definitely it seems on body_class


#9

Thanks pal,

Appreciate your help, Thanks for your time.