Search code examples
arrayswordpresswordpress-themingargs

posts_per_page and offset aren't working. Whats wrong?


So I'm using the following piece of code:

<?php 
$args = array('posts_per_page'=>4, 'offset'=>1);
$the_query = new WP_Query($args);
if (have_posts()) : while ( have_posts() ) : the_post(); 
endwhile;endif; wp_reset_postdata();?>

But it seems like my arrays are being completely ignored. What's wrong?


Solution

  • if you using in ajax you can try add post_status => "publish" to query.