• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

get_body_class

This free code checks the body classes and executes your code if the body class exists.

In this case, the code executes on any page which includes custom-class in the body classes. If so, the header and header markup is removed along with the nav menus and this text is printed in the genesis_header hook position : Replace this output value with you own

Click here to access free tutorials

To modify this code, replace the value for the $output variable, and replace the actions within the function to add or remove functionality.

You can check for an existing body class or a custom class added using code like this found in many Genesis child theme template files :


add_filter( 'body_class', 'genesis_sample_landing_body_class' );
function genesis_sample_landing_body_class( $classes ) {

    $classes[] = 'custom-class';
    return $classes;

}

If you inspect the element or source code and view the body classes, this is what you’ll find :

body-class

PHP Functions

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.