Support » Fixing WordPress » Pagination within page templates?

  • Resolved theronin


    I’ve setup a page template called ‘News’ which displays a list of the 5 most recent news entries and displays the_excerpt() allowing the user to click on the title to view the full article.

    Each news item is a Post in the category of “news” but they are output on a Page (as noted above).

    I’ve gone to add wp_link_pages() within the loop and after the_exerpt() but nothing displays. I’ve set the posts to display as 5 and I have 10 in the database. It shows the 5 most recent as it should be there just aren’t any page links at the bottom to flick to the next page of entries.

    I know I’m running WordPress as more of a CMS so I was just wandering that wp_list_pages() was being affected by the fact that it displayed within a Page Template? Should this still work?

    Is there anything which could be preventing the pagination controls from showing?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    as described in this article, is used for linking pageinated parts in pages, not page templates.
    added within the loop as described by you, it wil allow the posts to be split into multiple parts by inserting ‘<!–nextpage–>’ into the post content, in the html editor.

    however, you are probably looking for something like
    which would be included somewhere after the ‘endwhile’ of the loop.

    also check the use of the ‘paged’ parameter of ‘query_posts’

    Thanks for setting me straight on the use of wp_link_pages and thanks for pointing out post_nav_link too. This looks like what I need and having placed it outside the loop for the page in question I can now see the link to “Next Page ยป”. However, when I click on the link it refreshes the page but the same articles are shown rather than the previous 5 (I have 5 per page set).

    With regards to the ‘paged’ parameter of ‘query_posts’ I’m not sure if this will help at all. Because each page of my News section contains 5 Posts and these posts will grow over time I don’t want to define the total number of pages otherwise I’d have to go into the code and change it after every 5 new posts. I need this to be dynamic.

    Any ideas why the post_nav_link isn’t working?



    Forum Moderator

    the codex is not very clear with this pagination topic;
    see if this article helps:

    Bingo! You hit the nail right on the head with that link. That was the exact problem I’ve been having and the proposed solution works perfectly for me. Thanks for pointing that out, and yes, I agree with you and Stylized Web that the WordPress Codex really aren’t very clear about the topic. I didn’t realise that query_posts overrides nearly everything in the standard posts objects query, including the page offset.

    Thanks again, and I’ll keep it in mind for next time.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Pagination within page templates?’ is closed to new replies.