Query Ignoring ‘exclude’ Parameter?

WP_Query does not support an exclude argument. To exclude a post by ID, use post__not_in and pass it an array of IDs. Using your code above, your arguments could look like this: $args2 = array( ‘posts_per_page’ => 3, ‘post_type’ => ‘post’, ‘ignore_sticky_posts’ => 1, ‘orderby’ => ‘rand’, ‘tag__in’ => array( $first_tag, $second_tag ), ‘post__not_in’ => … Read more

WP User Query multiple AND OR query problem

I guess the search part is not working as you expect, because your search columns setup: ‘search_columns’ => ‘user_login’, is within the meta query and therefore not active. Move it out of the meta query part: $user_query = WP_User_Query( [ ‘search_columns’ = [ ‘user_login’ ], //<– array of column names … ] ); Otherwise the … Read more

Modify existing query and change order of posts

Was able to solve this by first registering the custom query var. https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars And then next I used the switch function: global $wp_query; switch ( $wp_query->query_vars[‘filter’] ) { case ‘random’: $recipe_args[‘orderby’] = ‘rand’; break; }

How to exclude products by tag from woocommerce shop page?

Add this to your functions.php function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘banana’ ), // Don’t display products with the tag “banana” ‘operator’ => ‘NOT IN’ ); $q->set( ‘tax_query’, $tax_query ); } add_action( ‘woocommerce_product_query’, ‘custom_pre_get_posts_query’ );