Using WP_Query () to query for new messages using the message identifier in the WHERE?

I was wondering if there is a way to use WP_Query (get_posts, etc.) to return messages with an identifier greater than the one provided.

I went through the WordPress code and skipped links to requests related to the post id, if possible even without a custom request.

Since it doesn't allow you to skip it with arguments, I tried to write a method that modifies the posts_where filter, but this does not seem to work.

add_filter( 'posts_where', 'filter_since_id');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    // Do Stuff
endwhile;
remove_filter('posts_where' , 'filter_since_id');

...

function filter_since_id($where = ''){
    $where .= " AND ID > 3'";
    return $where;
}
+3
source share
1 answer

It is explained that someone passing through can grab and leave:

add_filter( 'posts_where', 'filter_since_id');

function filter_since_id($where = ''){
    $where .= " AND ID > 3";
    return $where;
}
0
source

All Articles