If I am reading your code and description correctly, you can simplify that to:
$taxonomy = 'delivery_option';
$do = get_the_terms($post->ID,$taxonomy);
if (!empty($do) && !is_wp_error($do)) {
$do = array_shift($do); // assuming a single value as per the description.
$term = str_replace('-delivery','',$do->slug);
get_template_part('includes/sidebar-part',$term);
} else {
echo '<p>No custom include!</p>';
}
Note, I used WordPress’s get_template_part()
instead of PHP’s include()
as that is the more correct way to include template files.
Related Posts:
- get_the_term_list without links in 3.1
- wp_insert_term – parent & child problem
- Custom order of terms for custom taxonomy in admin and website
- Custom Fields and performance
- Creating a custom Admin panel
- Remove description in custom taxonomy edit screen
- Manipulating cookie on specific taxonomy archive page
- get_the_term_list without specific category
- Checking if a Page has an Associated Term?
- Extending wordpress search to include excerpts and taxonomies?
- wp_query to display custom taxonomy terms
- How to list all record from one custom taxonomy start with only one letter i.e A
- Removing the “Popular Terms” area from the Taxonomy Edit Screen in the Admin Area
- conditional statement for custom taxonomy
- Creating an Archive using a Custom Taxonomy
- List Recent Post Titles from Custom Taxonomies?
- Conditional display for custom fields/taxonomy
- Conditional Query of Custom Post Type and custom taxonomy
- Custom Taxonomy Term Caching?
- Some of my custom taxonomies are not showing but still counted in a WPMU set up
- add hirarchy of categories in products grid of visual composer
- Add success message to category add screen
- wordpress testimonials
- Hiding taxonomies with no children WP_Query & tax_query
- Creating conditional to display taxonomy term meta
- WordPress Custom post query sorting does not work
- Custom taxonomy not appearing in menu administration panel
- Changing select options based on previous select with PHP & AJAX
- Best structure for entering recipes in a WordPress theme?
- Proper WP conditional tag to check for existing taxonomies to list out terms with wp_list_categories?
- Get Terms for Page
- Add attribute taxonomy through code don’t appear in admin product page
- Best way to redirect taxonomy terms to pages
- Create alphabetical Pagination for custom taxonomy?
- Taxonomy Overview Page?
- Variable Not Working Inside is_author() Array
- Featured Images for Tags?
- If custom taxonomy else conditional [closed]
- Query Multiple Custom Taxonomies
- Use wp_list_categories to list parent categories from actual term
- Conditional if is single and part of the custom taxonomy
- Remove Custom metabox from particular page template is used
- Restrict viewing of posts by category, user role
- Assign a default description to new terms under a custom taxonomy
- WordPress tag or archive php file customization
- WordPress shortcode Issue!
- Why is it defaulting to “uncategorized” even after I select a custom taxonomy
- restrict access to specific urls on a specific period of time
- Trying to achieve row posts below category with multiple loops in custom tax
- How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?
- Custom Taxonomy, shows empty value (home page of website)
- Custom Search only for my Custom Taxonomy Page – data
- get_the_term_list without links in archive template title tags?
- How do test if a post is a custom post type?
- Using wp_query is it possible to orderby taxonomy?
- “tax_query” parameter not working with WP_Query
- How do I exclude a custom taxonomy from the post loop
- get_posts assigned to a specific custom taxonomy term, and not the term’s children
- How can I get only parent terms?
- How to modify a taxonomy that’s already registered
- Retrieve posts by term id custom query
- Change order of Custom Taxonomy List
- Get the the top-level parent of a custom taxonomy term
- Inserting terms in an Hierarchical Taxonomy
- get_terms – only top level
- Custom taxonomy terms not showing as list Gutenberg Editor
- Altering the appearance of custom taxonomy inputs
- How to only list the child terms of a taxonomy and not their parents?
- Get term SLUG by term ID
- Is ACF being a honey trap? [closed]
- Get term name from term ID?
- Check if Current Category has Children
- How to use taxonomies on attachments with the new Media Library?
- Hierarchical taxonomy UI
- WordPress taxonomy radio buttons
- How to prevent new terms being added to a custom taxonomy?
- Custom taxonomy, get_the_terms, listing in order of parent > child
- How to remove the tag cloud from custom taxonomy admin page?
- custom taxonomy and pages rewrite slug conflict gives 404
- Inserting a term into a custom taxonomy
- Count posts in custom taxonomy
- How to add images to taxonomies?
- How do I append multiple taxonomies to the URL?
- Read-only taxonomy (user can assign term but can’t create or edit existing terms)
- Remove taxonomy base or term from url
- Can you add the visual editor to the description field for custom taxonomies?
- Adding Category/Tag/Taxonomy Support to Images/Media
- Add default WordPress tag meta box to User Profile
- Custom Taxonomy Endpoint Pagination using paginate_links()
- How do I get the top-level terms in a custom taxonomy?
- Check if a post has any term in this custom taxonomy?
- Query Custom Post by Taxonomy Category
- Custom columns on edit-tags.php main page
- Loop through custom taxonomies and display posts
- How do I add a custom taxonomy as an option for menus under “Appearance” > “Menus”
- custom post type taxonomy “tag” archive : no post found
- How to get WooCommerce Product Category Link by ID?
- Order get_terms using a Custom Field
- Add custom taxonomy fields when creating a new taxonomy
- get_term_children for immediate children only (not grandchildren)