Articles of tax query

Specify number of posts in my 'tax_query'

I’m showing posts of the term ‘football’ belonging to the taxonomy ‘section’, and everything works perfectly but Where can I specify the number of posts I want to show? just like this: ‘showposts’ => 3 I do not know where to put it $myquery[‘tax_query’] = array( array( ‘taxonomy’ => ‘section’, ‘terms’ => array(‘futbol’), ‘field’ => […]

pre_get_posts: using tax_query only for certain post type

I have default post type posts (post type: post) and custom post type posts (post type: cpt). The latter has a taxonomy (cpt_tag). I would like to display on my front page all the default post type posts (unfiltered), and some of the cpt post type posts, only if they have a certain cpt_tag. The […]

pre_get_posts Tax Query not working for custom author page

I am using the theme TwentyTwelve and modified the standard post query in the file author.php with the following code: function wpd_author_query( $query ) { //CODE to set $current_user_name here //This gets the author from the URL $author = get_user_by(‘slug’,get_query_var(‘author_name’)); $current_user_name = $author->user_nicename; if ( $query->is_author() && $query->is_main_query()) { // your code to set $current_user_name […]

tax_query: What to pass when I want to have all terms?

… $args = array( ‘post_type’ => ‘wr_event’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => $order, ‘meta_value’ => $yesterday, ‘meta_compare’ => $compare, if ( is_null($cat) ) ‘tax_query’ => array( array( ‘taxonomy’ => ‘event_type’, ‘field’ => ‘slug’, ‘terms’ => $cat, ‘operator’ => ‘IN’ ), ) ); I’m confused, what do I pass in […]

Including all terms in wordpress tax_query

I’m a little bit confused, why I can’t include all the terms in tax_query automatically? My code: ‘tax_query’ => array( array( ‘taxonomy’ => ‘city’, ‘field’ => ‘slug’, ‘terms’ => array( nyc, boston, london ), ) ) What If I’ve dozens of cities? Isn’t it uncool to add them all manually?

WordPress tax query use operator LIKE

I have taxonomy color which is associated with a custom post type. I am listing all the post meta and the taxonomy in a table. I have a option in the table to search the posts matching the search value. when search key is entered it will do a ajax call to get the the […]

How do I sort posts by custom taxonomy?

I am trying to sort posts by custom taxonomy. I have a custom post type which is course-cpt and I have created custom taxonomies within it, I need to sort the courses by course-level (which is the taxonomy term) so that it displays like so: Course Name level 1 Course Name level 2 Course Name […]

Can't make a tax_query across different post types

I am attempting to build a tax_query, and I’m unable to make it behave. What I want to retrieve from the query are two different content types: A) Posts that are in a specific Category B) Portfolio items (custom post type) that are in a specific portfolio-category I could of course make two different queries […]

Query all posts in a given taxonomy

For sure it’s very simple, but I can not figure out how to do this. I need to query all posts that has a specific taxonomy set. Like this: $query03 = array( ‘numberposts’ => 5, ‘post_type’ => array( ‘video’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product’, ‘field’ => ‘slug’, ‘terms’ => **all_the_terms_in_taxonomy** ) ) […]

Query set using tax_query with relation 'OR' modifies category object?

(Update: Please see the edits far below.) The code: function itsme_better_editions( $query ) { if ( $query->is_category() && $query->is_main_query() ) { $query->set( ‘post_type’, array( ‘post’ ) ); $query->set( ‘tax_query’, array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => ‘intl’, ‘operator’ => ‘IN’ ) ) ); } return $query; } add_filter( ‘pre_get_posts’, […]