WordPress. get_posts compare with the ID value?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
16 views
how to make a sample id from wp_query?
to rule out if the 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' => '>=' ) ) ));
by | 16 views

1 Answer

0 like 0 dislike
1. First, meta_query does the subquery in the table wp_postmeta, wp_posts and not in the wp_postmeta table ID field is not - there is a post_id and meta_id.
2. To solve your problem fit the filter posts_where, with which you can add WHERE ID >= $currentid.
by

Related questions

0 like 0 dislike
2 answers
asked May 20, 2019 by jensen6720185
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 11, 2019 by Pavel_sp
110,608 questions
257,187 answers
0 comments
40,796 users