WordPress WP_Query offset parameter not working with search parameter

On a wordpress query every time i add the ‘s’ parameter or search the ‘offset’ and ‘posts_per_page’ will not work, it will query all posts by using the ‘s’ parameter only, why is that? am I missing something?

Basically i’m creating something like ajax load more plugin, the plugin doesn’t suit what i need so i’m improvising one using wordpress ajax with search and need to offset some results for load more functionality.

$args = array(
    'post_type' => 'post',
    'posts_per_page' => '2',
    'offset' => '2',
    's' => 'a',
    'category__not_in' => array(41),
    'orderby' => 'date',
    'order' => 'DESC'
);

$query = new WP_Query($args);

$psps = $query->get_posts();

Related posts

Leave a Reply