Tax query get first product with attribute value in pre_get_posts
Tax query get first product with attribute value in pre_get_posts
Tax query get first product with attribute value in pre_get_posts
Try this. I followed the WP_Query docs to build this. $args = [ ‘meta_query’ => [ ‘relation’ => ‘AND’, [ ‘_stock_status’ => [ ‘key’ => ‘_stock_status’, ‘compare’ => ‘EXISTS’, ], ‘_sale_price’ => [ ‘key’ => ‘_sale_price’, ‘compare’ => ‘EXISTS’, ], ‘_price’ => [ ‘key’ => ‘_price’, ‘compare’ => ‘EXISTS’, ] ] ], ‘orderby’ => [ … Read more
This is written on the assumption that this data will only be retrieved when the user ID is known, and always in full for that user. If any kind of filtering is needed, if you need to filter users themselves by this data, then this answer will no longer apply. One Row per User This … Read more
The main problem is the AND logic that wordpress uses when creating a sql query. This query will look for posts that have both author = 2 and meta query, additional_author that is LIKE 2. Your best bet is to create your own query to achive this result. I have created a static query for … Read more
I change it to get_posts() instead of new WP_Query and it works just fine. No idea what’s the problem with the query.
wp_Query with mutuplea values returns all posts
The solution for now is : create a plugin re-creating the shortcode with the current page slug. Naming the page slug like the category slug. And manually add the category to dflip. Couldn’t find better so far. // Disable direct access defined(‘ABSPATH’) or die(‘No script kiddies please!’); // use page slug to call dflip book … Read more
How can I modify the query by adding to the existing query?
Order (by ASC) posts with meta_key so posts without values are last
I think the problem is that you have multiple meta values so your order by should be more targeted, like this. $args[‘orderby’] = array( ‘mp_exists’ => ‘ASC’, ‘mp_not_exists’ => ‘ASC’, ‘title’ => ‘ASC’ ); I don’t know by what meta you want to order so I added both of them, remove as necessary.