WordPress.org

Forums

[resolved] Pagination Links (5 posts)

  1. adejones
    Member
    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">
    <ul>
    <li class="older"><?php next_posts_link('Older') ?></li>
    <li class="newer"><?php previous_posts_link('Newer') ?></li>
    </ul>
    </div>

    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?
    Thanks.

  2. vtxyzzy
    Member
    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
    Member
    Posted 2 years ago #

    Thanks,
    I actually changed my post query from:

    query_posts('cat=3,4,5');

    to:

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

    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
    Member
    Posted 2 years ago #

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

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

    Excellent, now works a charm, thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.