get_terms()
return all the terms in the taxonomy regardless of the current post.
So if current post does not have lang terms still this condition if ( !empty( $lang))
will be true
thus it will display the text Language.
Use get_the_term_list
instead of the_terms
which return the terms list instead of printing, so output can be used for both purpose.
Example:-
$lang = get_the_term_list( get_the_ID(), 'lang', ' ', ', ' );
if ( !empty( $lang)) {
echo '<li><strong>Language:</strong>' . $lang . '</li>';
}
Note: Recommended approach is to use
get_the_ID()
instead of global
$post->ID
Related Posts:
- Get related posts of child term of custom post type
- Variable not working in WP_Query
- Copy/Move selected taxonomy terms to another taxonomy for posts
- Define multiple prefixes for custom post type
- How to manage a dynamic multi-level page hierearchy system?
- Filter By Term Not Working – Custom Post Type
- wp_set_object_terms() not adding new term to custom post and custom taxonomy
- Display all posts in main category and 1 subcategory
- wp_get_post_terms on custom post type with custom taxonomies returning an empty array
- Custom Taxonomies not appearing in Admin
- Missing Posts in Custom Taxonomy List
- Custom Post Type Taxonomy Filters
- How do I do this with WordPress? Taxonomies?
- Disable block with taxonomies at post page
- Which post does a taxonomy term belongs to?
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- List custom taxonomy specific to one custom post type
- Custom Taxonomy back-end customizations
- Taxonomy custom post type URL
- How to Filter custom post type by taxonomy?
- Is it possible to have dedicated page for parent/child taxonomy?
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Limit amount of posts made within a custom taxonomy
- Issue on Creating Custom Tax Term Dynamically From Another CPT Meta-box On Publish
- list taxonomies from a custom post type
- Display a grid of taxonomy terms at root taxonomy page
- limit value taxonomy based on previous taxonomy value wordpress
- Several post types on WP Query by tag and taxonomy
- How do I display the taxonomy for a custom post type in an array
- How to conditionally redirect to the post from a taxonomy page?
- How do I check if the user is on a taxonomy term parent, child or grandchild page?
- How do I display the grand child items of a taxonomy term?
- Taxonomies relations
- Is it better to use WordPress Custom Post Types or Taxonomies?
- Full Custom Post Type List Organised by two Taxonomies
- WordPress Doesn’t Generate Taxonomy Archive
- Suggested Post and Taxonomy structure
- Custom post with more than one custom taxonomy
- Get the taxonomy of a post hierarchically
- Adding custom taxonomy in same menu place with two custom post types
- How to make custom taxonomy into drop down select in a custom metabox
- How to get list of taxonomy slugs ordered parents>childs?
- How do I share categories across multiple post types?
- Multiple tag cloud filtering
- Get url.com/post_type/taxonomy/term work!
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Taxonomy in URL
- Different Category system needed for the Custom Post Type
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- WP the_posts() on single-cars.php get category link
- How to Set Taxonomy Object Description?
- Custom select query for taxonomies that have posts categorized in another taxonomy
- Custom Taxonomy Is Being Pulled into a Page, But It Doesn’t Have A Hyperlink
- Querying two taxonomies with tax_query not woking
- Rename a slug label
- Hide specific taxonomies from a taxonomy list using ‘get_object_taxonomies’
- Custom taxonomy (categories) on custom post type return no results
- Hide meta box for everything BUT a certain custom post type
- get_category_link() for custom post type does not include custom slug rewrite?
- How to Display Posts From Category Within a Custom Taxonomy?
- Targeting categories in custom fields
- How can I create an automatic drop down menu with my tags?
- How to define a term for custom taxonomy
- List custom taxonomy as navigation – taxonomy pages with all it’s posts?
- Alphabetically sort a taxonomy.php template by post title
- Custom Post Types not queried in Custom Taxonomy archives or Native archives
- Get taxonomy singular name instead of taxonomy slug inside $taxonomy query
- Show Taxonomies with admin area for custom post type?
- Custom taxonomy template list not working (404)
- Use the custom post type archive for taxonomies?
- Rewrite custom post type with taxonomy
- display posts of custom post type with custom taxonomy
- WordPress multisite – is it possible to have different taxonomies for each site?
- My custom taxonomy is only displaying 1 of 3 terms
- Query custom post types & Taxonomies and list them in a table on a page
- Taxonomy template page not working
- How to show list of taxonomy terms associated with specific post?
- Changing CPT slug and taxonomy already registered in parent theme
- Creating custom post type posts and associating them with a post from another custom post type
- I have custom post type with custom taxonomy. But not found the taxonomy page..
- Group Custom post type in a taxonomy page by its child taxomony
- How to query Posts from a custom post type which contains a custom taxonomy?
- Custom Taxonomy Terms in Menu lead to which page?
- Getting List of child terms from custom taxonomy parent
- Different structure/content for posts from a custom post type
- List all posts in taxonomy term
- Post Editor: display categories from current post type taxonomy only?
- List all posts from custom post type by taxonomy
- Displaying taxonomy icon outside archive page
- Custom post type post taxonomies
- Connecting multiple post types? Or linking “News” posts with “Game” posts how?
- Custom Post Type used for FAQs Accordion
- Sort by Custom Post Type (Multiple Loop)
- Linking custom taxonomies and posts
- Archive templates based on taxonomies
- Show taxonomies from specific CPT
- How to Associate Posts with Pages
- insert a taxonomy for a custom post type