Support » Fixing WordPress » Homepage pagination

  • Resolved carbonmadex

    (@carbonmadex)


    When the blog posts are called in a custom page template with the below code the pagination works just fine:

    <?php global $paged;
    
    $bcat = get_option('of_blog_category');
    $bcatid = get_cat_id($bcat);
    
    query_posts(array(
    'cat'=>$bcatid,
    'posts_per_page' => 9,
    'paged' => $paged
    )); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    

    However when I set the page which uses this template as my homepage in “Settings – Reading”, the pagination stops working.

    What may be the reason for this? How can I solve it?

Viewing 1 replies (of 1 total)
  • Well I solved the issue by replacing the above code with this:

    <?php
    $bcat = get_option('of_blog_category');
    $bcatid = get_cat_id($bcat);
    if ( get_query_var('paged') ) {
    $paged = get_query_var('paged');
    } elseif ( get_query_var('page') ) {
    $paged = get_query_var('page');
    } else {
    $paged = 1;
    }
    query_posts( array( 'post_type' => 'post', 'paged' => $paged, 'cat'=> $bcatid, 'posts_per_page' => 9 ) );
    ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Homepage pagination’ is closed to new replies.