• Resolved callender

    (@jimcallender)


    Hi,

    I am using the 2010 theme, and using query posts for the homepage – showing latest 4 news category posts.

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("posts_per_page=4&cat=1"); ?>

    However, the ‘older posts’ link just loops to show the same page..

    Here is the permalink structure:

    Homepage – homepage.com
    Homepage – page 2 – homepage.com/page/2/

    Any advice on how to get this pagination working correctly would be appreciated!

    Thank you,

    J

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("posts_per_page=4&cat=1&paged=".$paged); ?>

    Thread Starter callender

    (@jimcallender)

    hmm, still not working.. see for yourself – http://banburywalker.com/site/labs/

    and scroll to bottom – click on older posts..

    Moderator keesiemeijer

    (@keesiemeijer)

    If this is a static front page use:

    <?php
    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("posts_per_page=4&cat=1&paged=".$paged);
    ?>

    Thread Starter callender

    (@jimcallender)

    Thanks for your help.

    Yes it’s a custom template – home.php, using a page within WordPress.

    The code you have supplied is not working for me. Syntax error line 25:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Moderator keesiemeijer

    (@keesiemeijer)

    You’re missing the start of the loop.
    try changing this:

    <?php if ( have_posts() ) : ?>
    <?php 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("posts_per_page=4&cat=1&paged=".$paged); ?>

    to this:

    <?php
    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("posts_per_page=4&cat=1&paged=".$paged);
    ?>
    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>

    Thread Starter callender

    (@jimcallender)

    superb! worked thank you!

    Moderator keesiemeijer

    (@keesiemeijer)

    You’re welcome. Glad you got it resolved.

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    How to add pagination in above code .
    Anyone can help me about that ?

    Please post your own topic and do read the Forum Rules before posting code.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Query post – Pagination not working’ is closed to new replies.