we meet here again 🙂
Try using this:
$term_list = wp_get_post_terms( $post->ID, 'persons', array( 'fields' => 'ids' ) );
and
'tax_query' => array(
array(
'taxonomy' => 'persons',
'field' => 'id',
'terms' => $term_list
)
),
AFAIK, the tax_query
accepts field by id
or slug
only (see here. And the wp_get_post_terms
accepts only names
(not slug), ids
and all
. So the match between them is only id
.
Update
If you need slug
, use this:
$terms = wp_get_post_terms( $post->ID, 'persons' );
$term_slugs = wp_list_pluck( $terms, 'slug' );
Related Posts:
- “tax_query” parameter not working with WP_Query
- Custom Taxonomy and Tax_Query
- pre_get_posts with tax_query causes empty result
- Including all terms in wordpress tax_query
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- search query within custom taxonomy term, post title and meta field
- tax_query not working on main query
- Ordering Posts with Custom Taxonomy Terms Array
- List taxonomy / category count showing list published posts only
- why do drafts return as part of wp_query?
- Is It Possible To Have Shared WordPress Custom Post Types?
- Dynamically tax_query terms
- How do I sort posts by custom taxonomy?
- pre_get_posts Tax Query not working for custom author page
- Get pages only with a specific taxonomy
- How to add autocomplete to custom taxonomy for CPT
- Custom taxonomy query not working with switch_to_blog
- ‘wp’ action hook not firing in admin and login?
- Taxonomy archive showing no results
- Get taxonomy parent using child slug (from merged taxonomies)
- Manipulate WP Query using a custom post type and multiple tax_query taxonomies
- Retrieve Custom Taxonomies according to posts selected
- Custom Taxonomy Not Working When added to WordPress Search
- Hiding taxonomies with no children WP_Query & tax_query
- Set tax_query conditionally with new WP_Query
- tax_query not working
- How to do a particular wp_query taxonomy search
- tax_query: Don’t show posts with parent term when they have a corresponding child term applied
- Create alphabetical Pagination for custom taxonomy?
- Custom arguments in WP_Query
- WP_Query tax_query – Show results if child has parent X
- how to access the $query variable inside taxonomy-xxx.php template file?
- how to use tax_query to apply both terms or one if one is empty
- Get Posts Related to Category By category id or slug
- Display just the Post’s parent Category, not child
- Tax-query on taxonomy doesn´t work
- how do you pull data from two taxonomies?
- WordPress Multiple Taxonomy Query
- How to set “manage categories” capabilities on a post type taxonomy but not on the general categories?
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Tax query array terms display out of order
- Advanced AND tax_query in sidebar with 2 taxonomies
- How to update WordPress custom SQL Select query for custom taxonomies so that syntax is correct?
- How to limit posts to 1 from each term with tax_query?
- wp_get_object_terms count on taxonomies within an category archive
- Complex Taxonomy scheme
- Remove taxonomy base or term from url
- Bulk term assignment for attachment taxonomies
- Taxonomy slug by term ID
- Create taxonomy with meta term using the WP Rest Api
- Best practices for complex taxonomies
- wp_get_object_terms – How can I order the resulting array by hierarchy?
- How to output the taxonomy term name in a widget
- custom post type category page
- Advanced custom fields – taxonomy terms images [closed]
- How to call custom taxonomy categories with shortcodes
- How do I make a custom taxomony appear like tags?
- How can I add buttons to a custom column in the taxonomy table?
- WP_Query on custom taxonomy works fine but fails if run through wp_ajax_
- JSON API – search by custom taxonomy
- 404 error- issues with pages after adding custom rules for posts
- Wrapping result of the_terms in a span with a class of the term name
- Howto control custum taxonomy order?
- Save custom taxonomy data in different table not in wp_options for my own plugin
- Taxonomy Rewrite Rules Redirecting Instead of Masking
- get_terms not returning any custom taxonomies
- WordPress implode & wp_insert_post question
- WP_Query parameter conflict
- How to write sql query to get the posts from a custom taxonomy term name
- How to display a custom taxonomy without a link?
- Get post count for current custom taxonomy
- Build filter for post-type + multi taxonomies + multi terms
- get_term_by works but get_terms doesn’t?
- Get custom taxonomy name (not the term) in custom post
- How to add custom content to custom taxonomy
- Fix Custom Taxonomy Display two times on each call
- Update Custom Taxonomy Value for a post based on custom date field
- Add filter to Admin list for all custom post types by their custom taxonomies
- How to output taxonomy term (incl. link to archive) on author.php?
- Featured Images for Tags?
- displaying posts from a custom post type tags
- Taxonomy page loading wrong data
- How to use custom slug and custom templates for custom taxonomy?
- Updating a custom post type’s custom taxonomy in a custom editor block
- how to show product custom taxonomies in woocommerce rest api
- Auto add custom taxonomy to permalink when save
- Custom taxonomy – no posts found
- WP Tax query & order by tax query not working
- Custom button on custom taxonomy listing page
- Custom Taxonomy Archives Page Errors
- Permalink Rewrite to include Custom Taxonomy Term
- Where is defined a custom register_taxonomy? [closed]
- Multiple Taxonomy in URL/Query – No Custom Post Type
- Displaying Custom Taxonomy List Posts By Slug?
- Show different sidebar on taxonomy pages when a default is set
- How can I get parent term from a child term
- ACF Display Taxonomy Image Field
- Search and filter with custom field in taxonomy
- Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)