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

WP SITES

2665

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

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

PHP Code

template_include

get_body_class

if else

array

class_exists

foreach

sprintf

add_action

printf

variable

Advertise · WPEngine · Genesis · Log in

  • How Premium Membership Works
  • Sign Up
  • Support
  • Subscription Details/Invoice
  • Tagged Tutorials
  • Access-Download Problems