What is the job of $section_name
? Also you must get an return; you if statement kill the default return. It is important, if your if statement fails.
maybe this works, but not tested, write from scratch.
add_filter( 'body_class', 'section_id_class' );
// add classes to body based on custom taxonomy ('sections')
// examples: section-about-us, section-start, section-nyc
function section_id_class( $classes ) {
global $post;
$section_terms = get_the_terms( $post->ID, 'section' );
if ( $section_terms && ! is_wp_error( $section_terms ) ) {
foreach ($section_terms as $term) {
$classes[] = 'section-' . $term->slug;
}
}
return $classes;
}
Related Posts:
- Displaying custom taxonomy terms active trail
- Changing stylesheet depending on custom taxonomy terms
- Styling Taxonomy Terms Individually
- Add A CSS Class To A Menu Item When A Custom Taxonomy Term is Present On Single Post
- Body class to each level of a hierarchical custom taxonomy
- How to add meta fields to custom taxonomy add/edit page?
- How to add/enqueue Custom CSS for a custom taxonomy page?
- How to prevent new terms being added to a custom taxonomy?
- How to add images to taxonomies?
- Read-only taxonomy (user can assign term but can’t create or edit existing terms)
- Can you add the visual editor to the description field for custom taxonomies?
- Adding Category/Tag/Taxonomy Support to Images/Media
- Include and Exclude Taxonomies From Archives & Feeds Using ‘pre_get_posts’
- Taxonomy menu with post count and multiple parents
- Sort Custom Post Type Archive by Taxonomy Term [duplicate]
- Large taxonomy (2000+ terms), causing WordPress to hang
- Is it possible to have a taxonomy archive that lists taxonomy terms?
- Check if current term is a child of another term
- Non-hierarchical custom taxonomy using checkboxes on edit-screen -> saving issue
- Dynamic page slug for Custom Taxonomies?
- How to pass posts_per_page and paged params query vars to custom taxonomy archive urls?
- show term description instead of list terms of custom taxonomy
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Exclude Custom Taxonomies
- How to get the top most term (top ancestor) of a custom taxonomy child term?
- Get custom category name from ID
- Edit post meta with checkboxes on front end
- Can I create custom taxonomy what dont creates slug pages?
- User role permissions based on taxonomies
- Search by type posts and taxonomy
- get_the_terms() to show all custom taxonomies
- Make tag cloud links consistent
- Get Taxonmy Term ID For Current Post
- Can I limit term selection to one plus parent?
- Insert form checkbox at bottom of taxonomy edit term page
- cannot get multiple loops using tax_query
- Taxonomy archive showing no results
- Hide posts having children terms when display posts by category in edit.php
- Get posts by term slug only
- Changing taxonomy term by slug (wp_update_term)
- Custom Taxonomy Term Caching?
- Controlling Taxonomy Category listings to hide and unhide specifics
- How do I create a custom archive page depending on the custom taxonomy type?
- How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?
- Add Custom Taxonomy for Blog Meta Info
- Include parent and child in category url
- woocommerce custom product category template
- Custom taxonomy multiples
- Is there a template file to list all terms of a given custom taxonomy?
- Assign terms to new capability for all taxonomies
- List of users inside custom taxonomy
- Rewrite Rules returning wrong data
- Output unique taxonomy terms of posts inside a loop
- Taxonomy terms can still be added when only assign_terms capability has been granted
- Use an HTML Element To Filter Taxonomies In WP Search
- Weekdays as terms – How to order taxonomy terms by ID in admin panel?
- How to display ACF taxonomy checkbox links on WooCommerce product category archive
- How to find taxonomy parent id from child taxonomy page?
- custom taxonomy not showing in Gutenberg
- Can I add other Custom Taxonomy to my syntax (functions.php)
- How to remove the search field in custom taxonomy ui?
- How to add hierarchical taxonomy with parent child relation to URL?
- How to show post for a particular term of custom taxonomy?
- Is there a way to change select-list for new custom taxonomy?
- How to get the term description in a taxonomy term archive query?
- Chaining Taxonomy Queries
- How to define %category% for custom taxonomies?
- How to list terms by first letter, as in A’s then B’s etc
- Taxonomy hide not working
- Admin only taxonomies?
- Create new Taxonomy, add extra fields, register terms AND extra fields values?
- See double taxonomy inputs in WP editor
- How to change custom categories term links?
- Dropdown (with onChange) with custom taxonomies
- Restructuring permalink with more than one taxonomies
- How to limit custom post category
- How to use two same taxonomy in same post differently?
- ajax drop down change second drop down data
- Redirect or Prevent Viewing of Custom Taxonomy’s Archives?
- Display taxonomy term slugs
- Automatically Populate Post Taxonomy Data Based on Post Author Meta Data?
- Get Posts by tag from a custom taxonomy
- Tax query array terms display out of order
- How to change taxonomy slug?
- Taxonomy to WordPress Permalinks of custom post type
- Avoiding stripping of HTML in Custom Taxonomy Meta Field
- Advanced AND tax_query in sidebar with 2 taxonomies
- Permalinks not working on MU network with domain mapping
- Create WordPress taxonomies based on theme settings
- Alternative for is_taxonomy() to workaround theme’s default sidebar
- Can I use get_term_children to show child terms if they exist and show something else if they don’t?
- Get custom taxonomy term url on archive page
- I’ve got a function that auto creates taxonomy terms – Can it auto delete them as well?
- Get custom taxonomy value of post and output posts in same taxonomy
- Head Code for Custom Taxonomy
- Adding new terms to custom taxonomy
- List posts grouped by children of a custom taxonomy
- Add text in custom taxonomy
- How do I check if a post has a term with a particular ancestor/parent?
- Best approach of implementing multi-select/checkboxes for taxonomies?