Filtering Body classes in pages according to taxonomy
-
I’m working on a plugin that modifies the titles of pages based on their hierarchy, page order, and a custom taxonomy.
If the page belongs has at least one term of this taxonomy, I want to modify the body classes, adding the slug for the taxonomy and the taxonomy term slug.
global $post; if (is_page()) { if(has_term('', 'book_page', $post->ID)) { $classes[]='book_page'; $_terms = wp_get_post_terms($post->ID,'book_page'); foreach ($_terms as $term) { $classes[] = $term['slug']; } return $classes; } else { return $classes; } } else { return $classes; }
This doesn’t pick up the presence of the taxonomy term. Am I using the has_term function correctly? Is there a better way to do this?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Filtering Body classes in pages according to taxonomy’ is closed to new replies.