You need to add a tax_query
parameter with a relation to do this,
$args = array(
'post_type' => array('my_custom_post', 'another_custom_post'),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'progression',
'field' => 'slug',
'terms' => $term->slug,
),
array(
'taxonomy' => 'sport',
'field' => 'term_id',
'terms' => array( 1, 2, 3 ),
'operator' => 'IN',
),
),
);
$query = new WP_Query( $args );
Of course, you’ll need arrange term_id
for the sport taxonomy relation.
You will find more examples and details about the taxonomy parameter in the WP_Query class reference
Hope it helps.
Related Posts:
- How to tell if $query_var isset?
- Function to delete a post, it’s children and it’s grand children (half way there already)
- Query posts based on previous query
- Advanced Custom Fields – Relationship post foreach query
- WordPress: paginating array using a foreach
- Why my query ‘REPLACE INTO…’ does not work?
- wpdb COALESCE won’t work
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- How to list commenters and days since last commented
- get csv of users with user_meta
- sort query results by newest
- Post with certain term and without any term
- Custom Query – Based on user input
- empty query breaks other queries
- How to add div blocks after certain set of post
- Problem in exploding the_content to array
- How to reset usual $query on search page to push custom $wpdb query there?
- get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)
- Order by meta value pro first then meta value free in my search function
- How to overwrite orderby with add_query_var
- Can’t update multiple rows with $wpdb query
- Custom SQL Query passing array to WHERE p.id
- Order by title – but now built in wordpress func, sort the_title
- Can’t get full post title if there a spaces in title
- Restrict query to last day with posts
- Custom query object with Simple-Fields custom date field
- Query does not return content
- working with term_relationships table
- Display posts between two particular dates
- pre saved posts query from db options table
- What is wrong with my wp query, cant exclude the category that i want
- Change the destination of the URLs in post.php
- Page with custom template make get request to a custom route – Pseudo code
- Order posts by date, but also give priority for a specific term
- WordPress query undefined offset in loop
- Can I make get_users() query global?
- $post->ID not working in combination with a custom query
- Get posts from category with custom query
- get_users with array as meta_value
- Issue with custom loop in Archive page
- How to display SQL query that ran in WC_Order_Query?
- Custom Query returns array, but I can’t see it’s elements
- Custom Post type slider with thumbnail navigation
- Parse error: syntax error, unexpected ‘}’ [closed]
- How to exclude posts for current user
- How to delete all posts, categories and tags from WordPress database
- how to insert missing tags into the posts through mySQL?
- Query posts dynamic date range
- Shortcode to pull posts
- How to read the value of a WordPress $query associative array (hash) key
- PHP -> SQL Query with Summing
- How to hide posts of a specific custom category in WordPress?
- Ideas how to search & replace post_content when string contains a newline?
- Related post based on content
- How to insert Collate into WordPress search query?
- Valid SQL query return empty
- mysql query – how to escape apostrophe?
- Combine “Exclude” Query in functions.php
- Slow Search Queries – How to exclude pages, media, excerpt, authors, private posts?
- Parse query filter in wordpress and relation
- Query the WordPress database to get data together with replaced information
- Random Page Rewrite
- How to write update query in WordPress to expire transients
- Query Nickname rather than Display Name in custom Woocommerce plugin
- $wpdb->prepare affecting the query?
- WordPress SQL search, how to handle SQL Injection?
- Waypoints + infinite scroll with custom query
- exclude pingbacks from wordpress SQL query
- Querying a custom post type, but not show duplicates
- How to interfere to default search to make it search in custom fields?
- Optimize slow SQL query for multiple meta values
- prepare function sql safe method
- get posts by tag to showing in a widget
- WordPress PHP syntax doesn’t seem to be working correctly
- Customizing the_tags output?
- Query for Custom Post Type UI Does Not Loop All the Post
- Querying for specific tags
- wp_posts query slowing down my website
- Get previous posts list
- How to get thumbnail with pure PHP in a WordPress database?
- how to replace old DW site with new WP site? [closed]
- Limit tags shown in post
- Mysql query not working on WordPress 4.2.2
- How do I get the index for a custom post?
- Updating with $qpdb->query() always returns 0 rows affected
- Why my query does not run with prepare
- Get the_field of Advanced Custom Fields in a custom query [closed]
- Querying with WP query using meta key price
- How to pull posts into two columns with different image sizes using $counter variable?
- Wrap/close ‘query’ for a first-letter ordered listing of posts
- Re-sort get_posts query results
- wpdb query with dynamic column name?
- How do you display the number of a post in a query?
- WordPress SQL query to tag all posts containing a specific word on title
- mySQL queries are executed twice on wordpress website
- How do I get all results from my query
- WP_User_Query with more than two custom meta values
- How to manage a particular “order by” for get_search_query()?
- List of Events with Multiple Dates: Only NEXT Date
- get_post_meta with WP_query