Reputation: 253
I'm trying to pull out all of the posts that have a meta value of Main, while trying to ignore the newest post created. I've looked here (WordPress site https://codex.wordpress.org/Class_Reference/WP_Query) but I can't figure out a way to ignore the newest post. It can't be by a set date, because it needs to always ignore the newest post.
$args = array(
'order' => 'DESC',
'meta_key' => 'main_story',
'meta_value' => 'Main',
'meta_query' => array(
'relation' => 'NOT IN',
array(
'key' => 'main_story',
'value' => Main,
'posts_per_page' => 1,
'order' => 'DESC',
),
)
);
I thought trying it this way not not get the newest post, but it hasn't worked. Is there an opposite of getting the meta_query, like ignore_meta_query, but you know, that works?
Upvotes: 0
Views: 171
Reputation: 27092
There are a lot of issues with your posted code...but you're looking for the offset
parameter of WP_Query
.
offset
(int) - number of post to displace or pass over. Warning: Setting theoffset
parameter overrides/ignores thepaged
parameter and breaks pagination. Theoffset
parameter is ignored when'posts_per_page'=> -1
is used.
$args = array(
'offset' => 1,
'posts_per_page' => 1,
'meta_key' => 'main_story',
'meta_value' => 'Main',
'meta_compare' => 'NOT',
);
Upvotes: 1