First you really shouldn’t use query_posts
for that use get_posts or WP_Query and second tax_query
accept an array of arrays
from the codex:
tax_query takes an array of tax query arguments arrays (it takes an
array of arrays)
so:
$terms=get_terms('tax_name');
$request=array();
foreach((array)$terms as $t)
$request[]=$t->slug;
$tax_q = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'tax_name',
'field' => 'slug',
'terms' => $request,
)
)
)
);
while ( $tax_q->have_posts() ): $tax_q->the_post();
Related Posts:
- How do I exclude a custom taxonomy from the post loop
- Filtering custom taxonomies
- Using WordPress to make a “Product Search” type navigation drilldown
- Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)
- get_query_var(‘paged’) always returns empty
- search query within custom taxonomy term, post title and meta field
- Showing posts by collection of specific terms and texonomy
- Problem with query_posts for a custom taxonomy in theme options
- Link to most recently created category of custom taxonomy in primary navigation menu
- How to display posts from a single category within a custom taxonomy
- Advanced Tax Query
- Sorting Posts Via Custom Taxonomy Values Using Checkboxes?
- Taxonomy.php issue with search and filters
- cannot get multiple loops using tax_query
- Alter post order on taxonomy template
- query_posts and custom taxonomy posts order
- quey posts from different categories with taxonomy
- Show all taxonomy’s terms’ posts having another taxonomy’s term in common
- List Posts For Terms Of A Custom Taxonomy For Any Post Type
- Using WP_Query and Query_post for the loop?
- How to write sql query to get the posts from a custom taxonomy term name
- one post per term taxonomy
- Loop through custom taxanomy in post and display custom fields from posts
- Insert taxonomy slug into loop class
- Using Custom Taxonomies to organise products – struggling to call a correct list
- Group posts in a category based on tags in custom taxonomy
- Transfer taxonomy to custom field
- How do I query multiple specific posts from a custom taxonomy?
- Can you orderby slug in a taxonomy archive page using WP_Query?
- query posts returns 10 records
- Getting taxonomies specific to categories
- How much worse is querying custom fields compared to custom taxonomies, quantitatively
- Group custom taxonomies based on tags contained in their posts
- How to show to show post list under the specific category name using jetengine query?
- WP REST API no longer supports filter param, so how do I get posts in a custom taxonomy?
- Include and Exclude Taxonomies From Archives & Feeds Using ‘pre_get_posts’
- Get value in custom field with taxonomy [closed]
- Get second level terms of custom taxonomy
- Modify Term Update Redirection
- How to get first post in a category of a custom taxonomy
- How to get the singular name of a custom taxonomy?
- How to hide custom taxonomy archives same way as hiding custom post types?
- Archive template for taxonomy terms
- pre_get_posts OR relation between taxonomy and author
- Custom Fields and performance
- Non-hierarchical custom taxonomy using checkboxes on edit-screen -> saving issue
- get_the_term_list without specific category
- Add Category Name to REST API
- Display the Terms from a Custom Taxonomy Assigned to a Post(inside the loop) in Hierarchial Order
- How to prevent posts duplicating when viewing a custom taxonomy term
- Is it possible to create exclusive custom taxonomy?
- Custom Taxonomy Archive BUG
- how does get_term_by know which term to return when the same term appears twice in a hierarchical taxonomy?
- Changing stylesheet depending on custom taxonomy terms
- Taxonomy with_front causes all
- Why is my taxonomy template not shown?
- How Can I Change a Taxonomy URL Based On The Originating URL?
- How To Assign “Taxonomy per Taxonomy”?
- How to add a Rewrite Rule / Category Structure
- How to have two different versions of a tag/category/taxonomy archive page?
- Rewrite Rule Working for all but one of the taxonomies created
- Get custom taxonomy for visual composer shortcode but not working?
- List related terms + taxonomies
- Multi-select field for Taxonomy can’t save the value
- How to Display a menu only if it has Posts in Custom Menu?
- how does the wordpress rest API work
- Why is flush_rewrite_rules mandatory after registering custom taxonomies?
- tax_query not working
- Control content before and after custom post type loop
- wp_query not resetting, last post hanging
- Set term on an attachment using wp_set_object_terms and want to display the full term text but it’s showing a slug instead
- custom taxonomy not showing in Gutenberg
- Why does wp_remove_object_terms not work?
- how to get term id from current post type instead of name
- Display children category images
- Dropdown taxonomy lists in admin menu
- How to define %category% for custom taxonomies?
- get_terms does not return any results for my custom taxonomy?
- How to Create Multi selection search Form using Default WordPress Category Terms, and Custom post Types Taxonomies Terms?
- How do I get the correct URL?
- How to replace custom post type with custom taxonmy in permalinks
- Cloning product not copying custom taxonomies
- deleted_$taxonomy not getting fired
- Query all images with certain tag in media library using visual portfolio plugin
- Problem with wp_list_category with custom taxomy
- Restrict viewing of posts by category, user role
- WP Query : strange behaviour with multiple no-hierarchical tax
- Dynamic drop down of child terms and then drop down posts
- Custom order of taxonomy using wp_get_object_terms and woocommerce_term_meta
- List terms and order by second word
- If term and page have the same slug, how can I view the term archive?
- Does a codex exist for creating meta boxes in taxonomy
- Run next query based on first query’s term
- Get the original menu item name string instead of the label
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- How to permanently delete a taxonomy
- How to query posts that are not related to any term of a taxonomy?
- Function code problem
- add_action with variable as a part of the $tag string
- How to display Custom taxonomy on custom post listing page [duplicate]