Change body_class() PAGE to HOME

Solved with: <?php add_filter( ‘body_class’, ‘alter_body_class’, 20, 2 ); function alter_body_class( $classes ) { foreach( $classes as $key => $value ) { if ( $value === ‘page’ ) { unset( $classes[ $key ] ); } } return array_merge( $classes, array( ‘home’ ) ); } ?>

Non Object Notice Error – How to fix please

Replace your code with as mentioned below: public function admin_body_class($classes) { global $wpdb, $post; $screen = get_current_screen(); $status=”parent-“; if( isset( $post->post_parent ) && $post->post_parent > 0 ) { $status=”child-“; } $classes .= ‘ ‘ . $status . $screen->post_type; return $classes; }

two body tags on all WP pages regardless of theme

I think this is the browser modifying the DOM due to a weird character you have in your body tag. When I view source in Firefox, I’m seeing the “character not recognized” box next to the body tag. This is also visible in Firefox inspector. Modern browsers automatically fix issues in your HTML for you … Read more

Add parent ID to body_class

Using the body_class filter // Use the filter ‘body_class’ add_filter( ‘body_class’, ‘parent_id_body_class’ ); function parent_id_body_class( $classes ) { // add parent id number to the $classes array $classes[] = wp_get_post_parent_id( $post_ID ); // return the $classes array return $classes; } Anyway, I recommend you to add some text to the id number, in order to … Read more

adding a custom time class to in theme twenty sixteen

Twentysixteen’s header and functions.php appear to support the body_class filter. add_filter(‘body_class’, ‘my_body_classes’); function my_body_classes($classes) { global $wp_query; $time = time() + ( get_option( ‘gmt_offset’ ) * 3600 ); $classes[] = ‘w’ . gmdate( ‘W’, $time ); if ( is_page() && $wp_query->post->post_parent ){ $classes[] = ‘parent-‘ . $wp_query->post->post_parent; } return $classes; }