WordPress.org

Ready to get started?Download WordPress

Forums

how do I add pagination into my theme? (5 posts)

  1. mr_badger
    Member
    Posted 3 years ago #

    Hi,
    I'm creating a theme but for some reason I cannot get even the basic next previous links to work in my pages.

    I have created a page template called page1 so my page url is http://www.websitename/page1 but when I add <div class="page-navigation"><p><?php posts_nav_link(); ?></p></div> it does show up the right amount of pages there should be but when I click on next it doesnt show the next set of blog entries.

    I do have a php query post on that page if that means anything but just need this solving and I know this will be very very simple to acheive but I just can't figure it out.

    Thankyou for any help.

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    does the query in your page template contain the 'paged' parameter?

    http://codex.wordpress.org/Function_Reference/WP_Query#Pagination_Parameters

    if you need assistance with the coding, post the query here (if the code is longer than 10 lines, please use the http://pastebin.com/)

  3. mr_badger
    Member
    Posted 3 years ago #

    no, it just queries the post category <?php query_posts('category_name=bars&showposts=5'); ?> so there is no paged parameter

  4. alchymyth
    Forum Moderator
    Posted 3 years ago #

    try and add the 'paged' parameter;
    example:
    <?php query_posts('category_name=bars&showposts=5&paged=' . get_query_var('paged')); ?>

  5. mr_badger
    Member
    Posted 3 years ago #

    yes, thankyou very much for your kind help, this has now solved the problem and is working fine.

    Thankyou.

Topic Closed

This topic has been closed to new replies.

About this Topic