Using WP_Query() to query newer posts, using post ID in the WHERE filter?

I was wondering if there is a way using WP_Query (get_posts, etc) to return posts with an ID greater than one that is provided..

I’ve been through the WordPress codex and missed any reference to querying posts related to a post ID, if it’s even possible without a custom query.

Read More

Since it doesn’t seep possible to pass it through with the arguments, I’ve tried writing a method that modifies the posts_where filter but that doesn’t seem to work either..

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;
}

Related posts

Leave a Reply

1 comment

  1. Clarified so that someone passing through can grab and go:

    add_filter( 'posts_where', 'filter_since_id');
    
    function filter_since_id($where = ''){
        $where .= " AND ID > 3";
        return $where;
    }