• hello

    here are the basic arguments for wp_query

    $args = array(
            'post_type' => 'post',
            'posts_per_page' => '12',
            'meta_key'   => 'bike_sold',
            'meta_value' => '1',
            'orderby'    => 'date',
            'order'      => 'DESC',
        );

    (these arguments are fine)
    The query returns a row of posts .. for example with ids like (1,2,3,4,5,6,7,8,9,10,11,12)

    The goal though is to retrieve a post/s with offset from the given ID with this custom meta/query arguments in mind.
    Something like this

    $args = array(
            'post_type' => 'post',
            'posts_per_page' => '12',
            'meta_key'   => 'bike_sold',
            'meta_value' => '1',
            'orderby'    => 'date',
            'order'      => 'DESC',
            'p' => 5,
            'offset' => 1
        );

    This obviously doesn’t work the way I want to because the query gets the specific post defined in “p” and thats it. No offset is taken into account.

    The question is how to get next/previous-offset post/s from the given id in a “row”.
    if we use the list of Ids above this might retrieve post with ID number 6
    (1,2,3,4,5,6,7,8,9,10,11,12)

    how to achieve this? any idea?

    (retrieving all posts find the one I’m looking for, find the next and previous etc. is not what I would like to apply 😉 )

The topic ‘wp_query offset from specific post ID with arguments in mind’ is closed to new replies.