So I have this
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post',
'posts_per_page' => 12,
'category' => 1165,
'meta_query' => array(
'meta_key' => 'price_special',
'value' => array('New Boat', 'Under Offer', 'Reduced', 'Just Added', 'Coming soon', 'New Build'),
'compare' => 'IN',
),
'suppress_filters' => false,
'meta_key' => 'price',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'paged' => $paged,
);
$query = new WP_Query($args);
but the meta_query is having no effect on the number of results and therefore the number of pages, can anyone tell me where I am going wrong please?
price_special
can have except forSold
would be much faster. Also,get_posts
is uncached by default, you should include'suppress_filters' => false
in your args. You also do not need to pass$custom_posts
intonew WP_Query
as you're doing twice as many queries as you need,new WP_Query( $args )
works just fineWP_Query
expects an array of arguments, not an array of posts, what you did was the same asnew WP_Query( get_posts( $args ) )
which is super weird and definitely does not work