Answer the question
In order to leave comments, you need to log in
WordPress. get_posts compare with ID value?
how to make wp_query fetch with compare id?
to exclude if id is greater than or equal to 15 for example?
$currentid = 15;
$query = get_posts(array(
'post_type' => 'posts',
'orderby' => 'ID',
'order' => 'DESC',
'exclude' => $currentid,
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'ID',
'value' => $currentid,
'compare' => '>='
)
)
));
Answer the question
In order to leave comments, you need to log in
1. Firstly, meta_query makes a subquery on the wp_postmeta table, not wp_posts, and there is no ID field in the wp_postmeta table - there are post_id and meta_id.
2. To solve your problem , the posts_where filter is suitable , with which you can add a WHERE ID >= $currentid.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question