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$argsarray:$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:
- How to add images to taxonomies?
- Can you add the visual editor to the description field for custom taxonomies?
- Check if a post has any term in this custom taxonomy?
- Custom taxonomy hide meta box but show in menu
- display posts with same taxonomy term
- Is there a way to disable a term rather than deleting it?
- Modify Term Update Redirection
- Check if current term is a child of another term
- get_terms() doesn’t return empty terms even though hide_empty is false
- SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement
- Remove Category description textarea
- Archive template for taxonomy terms
- How can I set up a category “overview” page?
- Sort posts by number of matched terms
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Possible to register multiple custom taxonomies in one function?
- How to get the top most term (top ancestor) of a custom taxonomy child term?
- Advanced Tax Query
- Function to limit the number of posts in taxonomy.php
- User role permissions based on taxonomies
- WP Query with custom taxonomy
- How to prevent posts duplicating when viewing a custom taxonomy term
- How to display custom taxonomy in multiple columns?
- get_the_terms() to show all custom taxonomies
- Custom taxonomies making WP very slow – Way to fix?
- Removing the “Popular Terms” area from the Taxonomy Edit Screen in the Admin Area
- Sorting taxonomy columns by meta value numeric
- Programatically added attribute, set to ‘show on product page’ automatically. Woocommerce [closed]
- Get Taxonmy Term ID For Current Post
- Is it possible to create exclusive custom taxonomy?
- ACF vs Taxonomies
- Reverse traversing taxonomy based on term_id
- Get Current Custom Taxonomy ID by Post ID
- Changing stylesheet depending on custom taxonomy terms
- Taxonomy with_front causes all
- Taxonomy archive showing no results
- I used the Tax-meta-class by bainternet but i still can’t get it to display any of the results.
- Autogenerate Front End Form Field With jQuery
- Changing taxonomy term by slug (wp_update_term)
- Rewrite Rule Working for all but one of the taxonomies created
- Taxonomies on custom taxonomies
- How to join result of different taxonomies?
- How to add Post Format Taxonomy Archive page in the menu?
- How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?
- How to get all taxonomies which can be added in menu?
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- woocommerce custom product category template
- Replace taxonomy permalinks
- Custom Taxonomy Term Archive Page Template that Filters 2 or more Taxonomies
- Custom Taxonomy with tax_query
- Override Taxonomy Template
- Get posts in certain Taxonomy terms for the current page url
- Trying to add taxonomy to get_categories() but it’s not working. How to fix this?
- Edit custom taxonomy description programatically
- Filter through custom taxonomy with an array of taxonomy IDs
- Dropdown taxonomy lists in admin menu
- Taxonomy archive template that shows posts from more than one taxonomy
- Taxonomy Overview Page?
- Order taxonomy terms wordpress
- 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
- 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
- new custom filed not showing in taxonomy
- How do I get the correct URL?
- Custom Taxonomies Archive Page 404
- How to replace custom post type with custom taxonmy in permalinks
- Cloning product not copying custom taxonomies
- How To Create Dynamic Permalink To Custom Taxonomy List of Current Posts?
- Dropdown (with onChange) with custom taxonomies
- ACF Custom field not showing in Timber Taxonomy page
- How to get a terms and posts associated with another term?
- Displaying subcategories and then posts in taxonomy template
- 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
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Taxonomy term breadcrumb; how?
- add custom fields in custom taxonomy meta box in wordpress-3.5.2
- How to permanently delete a taxonomy
- Advanced AND tax_query in sidebar with 2 taxonomies
- Alternative for is_taxonomy() to workaround theme’s default sidebar
- Get custom taxonomy term url on archive page
- Custom Taxonomy Template Variables Available?
- Display woocommerce product_cat child terms with thumbnails
- Adding new terms to custom taxonomy
- Group custom taxonomies based on tags contained in their posts
- How do I create a term for every value of a post meta?
- Save selected terms in order of custom taxonomy in post
- Add text in custom taxonomy
- How do I check if a post has a term with a particular ancestor/parent?
- Taxonomy entries are spawning copies of existing entries with the new title as the existing ID, since upgrade
- How to enforce a requirement for custom taxonomy
- Change taxonomy key of existing and future taxonomy posts