You should no longer use the legacy function parameter format. Instead, as the documentation says, use the get_terms( $args )
format:
Since 4.5.0, taxonomies should be passed via the ‘taxonomy’ argument
in the$args
array:$terms = get_terms( array( 'taxonomy' => 'post_tag', 'hide_empty' => false, ) );
And as for getting only the terms assigned to the current or a specific post, you can either use the object_ids
parameter with get_terms()
, or simply use get_the_terms()
.
So for examples:
$post_id = get_the_ID();
$countries = get_terms( array(
'taxonomy' => 'country',
'object_ids' => $post_id, // set the object_ids
) );
// Or just use get_the_terms():
$countries = get_the_terms( $post_id, 'country' );
Related Posts:
- Using wp_query is it possible to orderby taxonomy?
- How to add images to taxonomies?
- Can you add the visual editor to the description field for custom taxonomies?
- custom post type taxonomy “tag” archive : no post found
- Get taxonomy names by post id
- Return only the custom sub-term for custom post type, do not echo term-parent
- Get total number of comments from posts in a specific custom taxonomy
- Check if current term is a child of another term
- Custom hierarchal taxonomy loses interface hierarchy when selecting parent & children
- get_terms() doesn’t return empty terms even though hide_empty is false
- Formating the_terms() function output
- Custom taxonomy on users with UI
- Post tags saving as both tag name & tag ID on post update when tags are displayed as checkboxes
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Taxonomy Relationships
- How to get the top most term (top ancestor) of a custom taxonomy child term?
- Combine multiple custom user taxonomy in single url
- Add custom taxonomy to default category taxonomy?
- Display sub-taxonomies based on SELECTED parent-taxonomy
- Checking if a Page has an Associated Term?
- What are terms and taxonomy, how they related to post and how these three are stored in database?
- Taxonomy , subtaxonomy,child taxonomy of a product woocommerce
- Get terms ordered by post date
- How to display custom taxonomy in multiple columns?
- How can I get WP to build a feed based on multiple taxonomy terms
- Change permalink of post if it belongs to custom taxonomy
- Get pages only with a specific taxonomy
- Share taxonomy between user and posts?
- ACF vs Taxonomies
- Reverse traversing taxonomy based on term_id
- How to filter terms from a custom taxonomy by a usermeta value on all screens and templates
- How to obtain the link/URL to the feed of a custom taxonomy?
- get_term_children doesn’t return an array of children terms
- Use get_the_terms to list subcategories of custom taxonomy
- Get taxonomy parent using child slug (from merged taxonomies)
- Custom taxonomy [year] is directing to yearly archive
- Display Taxonomy Terms in an option tag with value being the slug
- Modify “View” in admin panel for custom taxonomy
- Taxonomies on custom taxonomies
- How to join result of different taxonomies?
- Hide product categories and taxonomy terms in menu if empty
- Custom taxonomy forms for user profile
- How to add Post Format Taxonomy Archive page in the menu?
- Query posts by taxonomy with current term
- get the taxonomies terms associated with users
- Add Taxonomy Subcategory To Permalink
- problem in taxonomy-{taxonomy}.php pagination
- Create custom taxonomy and Display in metabox dropdown
- Custom Taxonomy with tax_query
- Get posts in certain Taxonomy terms for the current page url
- How to add images to taxonomy terms? [duplicate]
- Why get_page_template() doesn’t show taxonomy template file name?
- Trying to add taxonomy to get_categories() but it’s not working. How to fix this?
- Edit custom taxonomy description programatically
- View the complete list of a taxonomy in the navigation menu
- Get name of taxonomies of current page
- Filter through custom taxonomy with an array of taxonomy IDs
- Add custom taxonomy as a css class
- Taxonomy page shows category in title
- Query custom taxonomy for category including children
- Taxonomy Overview Page?
- Order taxonomy terms wordpress
- Only display latest custom taxonomy post
- Unable to get the Parent Custom Taxonomy Terms
- How to get the term description in a taxonomy term archive query?
- How to define %category% for custom taxonomies?
- Unsetting post_tag taxonomy breaks term description for other taxonomies
- Taxonomies on Pages with Custom Formatting
- How to combine taxonomies into URL?
- Why do my quick edits for custom taxonomies not show on the post frontend?
- Prioritise Pages over Taxonomy Term Root Archive, but not Taxonomy Term Child Archives
- Tracking the name of a custom taxonomy
- Add terms to a taxonomy archive from within the same taxonomy
- Show recent posts from a custom taxonomy in wordpress
- new custom filed not showing in taxonomy
- Fill New Taxonomies
- how do you pull data from two taxonomies?
- problem : Custom taxonomy template not showing
- Filter “get_terms” query
- How To Create Dynamic Permalink To Custom Taxonomy List of Current Posts?
- Dropdown (with onChange) with custom taxonomies
- generate random slug when adding taxonomy
- How to get a terms and posts associated with another term?
- How to use two same taxonomy in same post differently?
- Sort Taxonomy List by Custom Values
- Display taxonomy term slugs
- Can I use multi (sub) levels of relation (AND | OR) on custom query?
- How to display custom taxonomy
- Taxonomy term breadcrumb; how?
- Advanced AND tax_query in sidebar with 2 taxonomies
- Using wp_query is it possible to orderby taxonomy?
- Alternative for is_taxonomy() to workaround theme’s default sidebar
- Get custom taxonomy term url on archive page
- Custom Taxonomy Template Variables Available?
- Adding new terms to custom taxonomy
- Group custom taxonomies based on tags contained in their posts
- is_tax not working for custom taxonomy
- Add custom display condition to Elementor Theme Builder for custom taxonomy children, grandchildren, and great-grandchildren
- Add text in custom taxonomy
- How do I check if a post has a term with a particular ancestor/parent?