WP_Query author parameter not working

First, the author parameter is parsed and appended to the author__in and author__not_in query parameters. Then author__in or author__not_in array is processed. These can be arrays created from author parameter or arrays passed as query parameteres author__in / author__not_in or created from a mergion author parameter with author__in / author__not_in parameters. Parameters author__in and author__not_in … Read more

Why in my query is display two title?

Try this. The code has comments where modified. <?php // args $args = array( ‘showposts’ => 5, ‘post_type’ => ‘post’, ‘orderby’ => ‘date’, // ‘order’ => ‘ASC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘type_id’, ‘value’ => ‘News’, ‘compare’ => ‘LIKE’ ), ) ); // query $the_query = new WP_Query( $args ); ?> … Read more

Query where ANDing slug values not working

You can do this using the WP APIs like this: $args = [ ‘post_type’ => ‘post’, ‘tax_query’ => [ ‘relation’ => ‘AND’, [ ‘taxonomy’ => ‘your_taxonomy_name’, ‘field’ => ‘slug’, ‘terms’ => array( ‘arizona’, ‘speech-language-pathology’ ), ] ], ]; $query = new WP_Query( $args ); Then you can use $query as you would any standard post … Read more

WP_QUERY with group by with custom fields

(Revised answer) So after discussing via the comments, what you really need is a custom ORDER BY clause, which in WordPress post queries (WP_Query), you can set the clause via the posts_orderby filter just like you can set custom GROUP BY clause via the posts_groupby filter. The order that I need is June – 2019 … Read more

Hide products in uncategorized category from search results

Try to add the following lines of code at the end of your theme’s functions.php file: function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘uncategorized’ ), ‘operator’ => ‘NOT IN’ ); $q->set( ‘tax_query’, $tax_query ); } add_action( ‘woocommerce_product_query’, ‘custom_pre_get_posts_query’ ); … Read more

How to combine two WP_Query objects?

What about just querying for both terms and increasing the posts_per_page count. $category_query = new WP_Query([ ‘posts_per_page’ => 36, ‘post_type’ => ‘product’, ‘tax_query’ => [ [ ‘taxonomy’ => ‘product_cat’, ‘terms’ => [ 120, 121 ], ‘field’ => ‘id’, ‘include_children’ => false ] ] ]); EDIT: Running a query with more that one term and guarantees … Read more