Adding body class to html tag that already has language attrubutes?

Maybe you could use a filter to add the current language of the website to the body class. add_filter(‘body_class’, ‘language_in_body_classes’); function language_in_body_classes($classes) { $classes[] = get_bloginfo(‘language’); return $classes; } Edit : maybe I misunderstood what you wanted. There is actually a language_attributes filter but I do not think it would be very standard to add … Read more

Body class to each level of a hierarchical custom taxonomy

Use is_tax instead of is_category, and update get_ancestors to get taxonomy from the queried object: add_filter( ‘body_class’, ‘custom_cat_archiev_class’ ); function custom_cat_archiev_class( $classes ) { if ( is_tax( [‘custom_tax_1’, ‘custom_tax_2’] ) ) { $term = get_queried_object(); $ancestors = get_ancestors( $term->term_id, $term->taxonomy, ‘taxonomy’ ); $classes[] = ‘catlevel-‘ . ( count( $ancestors ) + 1 ); } return … Read more

Adding Custom Body Class for Page: Shop

you could try to use this: add_filter(‘body_class’, ‘custom_body_class’); function custom_body_class($classes) { global $post; if ($post->ID == 346) { $classes[] = ‘services’; } return $classes; } This can be used anywhere as its pulling the global variable first.

Add top parent page id to body class

found it: add_filter( ‘body_class’, ‘dc_parent_body_class’ ); function dc_parent_body_class( $classes ) { if( is_page() ) { $parents = get_post_ancestors( get_the_ID() ); $id = ($parents) ? $parents[count($parents)-1]: get_the_ID(); if ($id) { $classes[] = ‘top-parent-‘ . $id; } else { $classes[] = ‘top-parent-‘ . get_the_ID(); } } return $classes; }

Why does admin_body_class not work?

This works for the admin backend; I needed to restructure the filter to be able to add a priority: function add_admin_body_class($classes) { $user = wp_get_current_user(); foreach ($user->roles as $user_role) { $classes .= ” role-{$user_role}”; } return $classes; } add_filter(“admin_body_class”, “add_admin_body_class”, 9999);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)