tax_query not working?
tax_query not working?
tax_query not working?
Tax_Query not working – connecting to second wordpress database
add the ‘date_query’ parameter to your query and include the current year. $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 5, ‘post_status’ => ‘publish’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘week’, ‘field’ => ‘slug’, ‘terms’ => date(“W”, strtotime(“this week”)), ) ), ‘date_query’ => array( array( ‘year’ => date(“Y”) ) ) );
Change operator to IN: array( ‘taxonomy’ => ‘features’, ‘terms’ => $feature_slugs, ‘field’ => ‘slug’, ‘operator’ => ‘IN’, ), That will query posts that have any of the terms in $feature_slugs, rather than all of the terms, which is what AND does. Also, I can see you’re using the POST method for this search. That type … Read more
posts_per_page in a tax_query
My solution to this ended up splitting this into 2 queries: Get the IDs of all the parent products I want to ignore Get all the variations that don’t a post_parent from that list of IDs $archived_products = wc_get_products( array( ‘type’ => array( ‘variable’, ‘variable-subscription’ ), ‘paginate’ => false, ‘limit’ => -1, ‘category’ => array( … Read more
WordPress post_status and meta_query
I’ve found the solution by myself. In brief: use ‘order’ => ‘DESC’ The long story: Since I was doing the first page query via php (standard loop), and instead, the above is done via ajax, passing pagination (thus page 1 is php, the following are ajax), there was a mismatch about the order. I was … Read more
The problem is that you’re passing a string with commas in it, not an actual array. The result of: foreach ( $categories as $cat ) { $filter = get_term_by( ‘id’, $cat, ‘portfolio-category’ ); if ( ! empty( $filter ) ) { $query_filter .= $filter->slug . ‘,’; } } Is: ‘one,two,three,’ Not an array. So you’re … Read more
No custom programming answer: A plugin like https://facetwp.com/ will allow you to set up filters as you have described. Custom programming answer: You can create a shortcode that renders fields for the user to check and submit. Then, attach a javascript submit handler to the form so that when the user checks a box or … Read more