Ready to get started?Download WordPress


[resolved] Pagination Links (5 posts)

  1. adejones
    Posted 2 years ago #

    Hi guys
    I have never added pagination links in to a theme of mine before so could someone please help?
    I have a news page showing posts from 3 news categories, and a sub-page for each news category, but obviously with the news page showing posts from all 3, there are quite alot of posts.
    I have put the following:

    <div class="pagination">
    <li class="older"><?php next_posts_link('Older') ?></li>
    <li class="newer"><?php previous_posts_link('Newer') ?></li>

    just after:
    <?php endwhile; ?>

    I have then gone in to the Reading settings and set number of posts to 10, my "older" link appears at the bottom of the list of 10 posts but when clicked, it just refreshes the same 10 posts.

    Any help please?

  2. vtxyzzy
    Posted 2 years ago #

    Your query may be lacking the 'paged' argument. See this Codex article section on pagination: http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

  3. adejones
    Posted 2 years ago #

    I actually changed my post query from:



    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'cat' => 3,
    	'paged' => $paged

    This makes it work, but i want to display categories 3, 4 and 5 so not sure how to make that work in the array, i tried 3,4,5 but this just displayed 3 and i tried adding 'cat' => 4, under 3 but this only showed 4.

  4. vtxyzzy
    Posted 2 years ago #

    Change the 'cat' argument to 'category__in', like this:

    'category__in' => array( 3, 4, 5 )
  5. adejones
    Posted 2 years ago #

    Excellent, now works a charm, thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.