get_the_term_list()
returns a string of HTML for the list of taxonomy terms on the given post. Without giving values in the optional arguments it would look like this:
<a href="http://example.com/type/roast/" rel="tag">Roast</a> <a href="http://example.com/type/type2/" rel="tag">Type 2</a>
So $type == 'roast'
would not be true because the value isn’t anything close to 'roast'
.
Even if it returned an array like array( 'roast' )
it wouldn’t be true because 'roast'
does not equal array( 'roast' )
.
If you want to check if a post has a given term in a taxonomy, use the has_term()
function:
if ( has_term( 'roast', 'type' ) ) {
}
Related Posts:
- How do I exclude a custom taxonomy from the post loop
- Display category posts grouped by taxonomy
- display posts with same taxonomy term
- Including all terms in wordpress tax_query
- Display one post from each term in a custom taxonomy [closed]
- Is it possible to sort the post based on a custom field?
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Group posts that matches a term in a loop
- Custom taxonomy template loop
- How to handle “the_terms” inside loop
- Modify main loop in taxonomy archive page
- All posts are still shown when adding category argument to query
- Operations with custom fields values in a loop
- echo current taxonomy id for this loop?
- How do I Use Multiple Loops with WP_Query?
- How to adjust code to refresh a dropdown box with tags that are active on filtered category listing
- How can marge these loop code?
- How do I display a list of posts under all hierarchical children of the current taxonomy?
- Posts in loop displaying all taxonomies
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- where is the 4th taxonomy terms? taxonomy terms is disaapearing in the loop
- Display all posts that use a custom taxonomy
- How can I reduce amount of ifs and else ifs in this specific block of code?
- Returning One custom taxonomy term name
- Exclude taxonomy term from all loops, but having it on widget
- Using WP_Query and Query_post for the loop?
- Loop to display ONLY custom taxonomy parent information [closed]
- Loop through custom taxanomy in post and display custom fields from posts
- List terms of custom taxonomy if matches other taxonomy
- Only display latest custom taxonomy post
- how to get the post id in the option tag
- How to get the term description in a taxonomy term archive query?
- Chaining Taxonomy Queries
- Problem with sorting in custom child taxonomy archive page
- How to add a shortcode function that returns the taxonomy slug of the actual post within the loop
- Group posts in a category based on tags in custom taxonomy
- How to loop custom posts that have an exact match in taxonomy terms?
- Get post meta value outside of the loop
- ACF – Get unique values of array
- Remove Custom metabox from particular page template is used
- Custom taxonomy shows full articles
- Is it possible to sort the post based on a custom field?
- Output slugs to use as class names for every taxonomy a post is attached to
- Multi level archive
- List active taxonomy terms
- sort Posts by custom user filed
- How to get name of custom taxonomy
- Query pages by child term
- Query Number of Loaded Posts in Loop
- Trying to achieve row posts below category with multiple loops in custom tax
- Custom Taxonomy + JQuery Tabs
- WordPress show posts from children terms of a taxonomy term
- Loop custom post type by taxonomy (Category)
- Get custom taxonomy value of post and output posts in same taxonomy
- How do I create a term for every value of a post meta?
- How home my code doesn’t display any feature image? Looping through post from a taxonomy and not getting feature images back
- Loop posts without any taxonomy
- How to looping taxonomy terms?
- get_posts assigned to a specific custom taxonomy term, and not the term’s children
- How can I get only parent terms?
- Display all posts in a custom post type, grouped by a custom taxonomy
- get_terms does not return any results for my custom taxonomy?
- How to display warning on post editor when trying to add new term to custom taxonomy?
- How do you remove a Category-style (hierarchical) taxonomy metabox?
- Is there a way to import terms into WordPress?
- get_terms() doesn’t return empty terms even though hide_empty is false
- Custom metabox for menu administration page?
- Remove Custom Taxonomy Base
- Retrieve custom taxonomies
- why do drafts return as part of wp_query?
- Populating dropdown menu with hierarchical taxonomies
- Taxonomy archive template to have conditional logic for displaying child categories
- How can I allow a custom taxonomy for certain roles?
- Specifying a size when displaying an image associated with a taxonomy through ACF
- How to check if do_shortcode will be execute directly in a template php file
- I used the Tax-meta-class by bainternet but i still can’t get it to display any of the results.
- Custom permalinks with hierarchical taxonomy – getting PHP warning
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- Render P2P metabox per taxonomy term
- Replace taxonomy permalinks
- How to rename custom taxonomy URL with extra words
- Separate tags with semicolon
- Removing “trashed” posts from post count in custom taxonomy terms?
- WordPress cannot find user taxonomies on frontend
- Taxonomy archive template that shows posts from more than one taxonomy
- Drop-down filter doesn’t retrieve custom taxonomies
- Why is the category item count not updating after assigning a category?
- Add custom taxonomy for post using cron job
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- How to show one post content in another post content which has same terms?
- How to set “manage categories” capabilities on a post type taxonomy but not on the general categories?
- WordPress Custom Post Type and sort by Tags
- How to update WordPress custom SQL Select query for custom taxonomies so that syntax is correct?
- Display term description on hover using get_the_term_list
- Search and filter with custom field in taxonomy
- is_tax not working for custom taxonomy
- Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)
- wp_add_object_terms cant recognize a post ID
- Foreach for get_the_terms for hierarchical taxonomy don’t repeat Top Level Terms if contains multiple Second Level Terms
- Gravity Forms with Advanced Post Creation Add-On not updating ACF fields on custom taxonomy