Set both meta_query and tax_query using wp_query->set

Just use another set() method: if ($value[‘pRange’] && $value[‘tags’]) { $wp_query->set(‘tax_query’, array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), array( ‘taxonomy’ => ‘pa_branding’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), ) ); $wp_query->set(‘meta_query’, array( ‘relation’ => ‘AND’, … Read more

WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank

If you haven’t done so already, I would recommend you to turn on debug logging in wp-config.php as it makes it easier to trace the error in your code. // added to wp-config.php define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); // find error.log in /wp-content, shows backtrace for errors define( ‘WP_DEBUG_DISPLAY’, false ); // … Read more

How to add tax_query to $args with concatenation

Try this… <?php if ( $value[ ‘priceRange’ ] == 0 && $value[ ‘tags’ ] == 0 && !$value[ ‘type’ ] ) { if ( !$value[ ‘priceRange’ ] ) { $value[ ‘priceRange’ ] = array( 0, 1000000 ); } $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1, ); } if ( $value[ ‘priceRange’ ] == … Read more

exclude product with available tag

You can setup a tax_query with the NOT IN operator. WP_Query( array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 500, ‘tax_query’ => array( ‘relation’ => ‘AND’ array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘cars’ ), ), array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘whatever_tag_i_dont_need’ ), ‘operator’ => ‘NOT IN’, ), ), … Read more

How to exclude a taxonomy from shop & search page wooCommerce?

This might help you with Shop page listing: https://docs.woocommerce.com/document/exclude-a-category-from-the-shop-page/ And for Search page, here is a snippet that might help: function exclude_services_category_products_from_search( $query ) { if ( is_search() && !is_admin() ) { $array_with_service_category_id = []; $tax_query = $query->get( ‘tax_query’ ) ?: []; $tax_query[] = [ ‘taxonomy’ => ‘product_cat’, ‘terms’ => $array_with_service_category_id, ‘field’ => ‘term_id’, ‘operator’ … Read more

Very complex post query

I got inspired in solving my problem by this thread! The idea is to create individual queries (unordered to save time, as sorting is not needed at this stage) to get the post IDs that meet your criteria; then take those IDs and run a final query with the IDs as the criteria to get … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)