On a wordpress query every time i add the 's' parameter 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();
  • Does it make any difference to add 'suppress_filters' => true ? – birgire Apr 7 '15 at 11:09
  • @birgire i'm afraid but i can't find the 'suppress_filters' parameter in the wordpress codex for wp_query?? – Bryan Estrito Apr 7 '15 at 12:35
  • I don't know about the Codex, but I can just refer you to the source code of WP_Query, because there might be some posts_where filters interfering with your query that. – birgire Apr 7 '15 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.