Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I set up wordpress newly and add next previous pagination in home page using following code

next_posts_link('Older Entries »', 0);
previous_posts_link('« Newer Entries', 0);

Pagination URL work correct. when click previous link it go to http:www.mydomain.com/blog/page/2/ URL but content not load. IT shows same first page blog post list. I have 70 blog posts and each page show 4 post. How do I load post in pagination URL? Do I need to make any .htaccess or WP setting change?

$args = array('numberposts' => 4);
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); 
$a = get_post_custom();
    $blogroll_image = $a['mainImage'];
    print('
    <section class="main_post bg_white fl">
        <section class="post_img fl">');
    print('<a href="' . get_permalink() . '"><img src="'.$blogroll_image[0].'" width="385" height="385" alt=""/></a>'); 
    print('</section>
        <section class="post_content fl col_light_blue">
        <p>' . get_the_date() .' </p>');
        the_title('<a href="' . get_permalink() . '"><h1 class="col_light_blue">', '</h1></a>'); 
    print(the_excerpt('<p>', '</p>'));
    print('</section>   
    <!-- end .main_post -->
    </section>
    <div class="spacer_1px"></div>');   
endforeach;
        next_posts_link('Older Entries »', 0);
        previous_posts_link('« Newer Entries', 0);
share|improve this question
    
are you calling query_posts or otherwise altering the query in your template? –  Milo Oct 4 '12 at 5:41
    
Yes I am calling query_posts –  miuranga Oct 4 '12 at 5:42
    
Could you paste your code, do you have it on the index.php or another page template? –  jepser Oct 4 '12 at 5:45
1  
see this answer and this answer. don't use query_posts to alter the main query. post the query code you are using in your template if you need help fixing it. –  Milo Oct 4 '12 at 5:46
1  
it's not clear why you're using query_posts or get_posts at all, WordPress does the main query for you before loading the template. if you simply want to change posts_per_page to something other than your site-wide settings, use pre_get_posts. –  Milo Oct 4 '12 at 14:19
show 4 more comments

1 Answer 1

up vote 0 down vote accepted

It's not clear why you're using query_posts or get_posts at all, WordPress does the main query for you before loading the template. If you simply want to change posts_per_page to something other than your site-wide settings, use pre_get_posts.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.