WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination, need help... (3 posts)

  1. Spencer Hill
    Member
    Posted 3 years ago #

    When I paste the code below into page-sample.php only one post appears and the pagination is absent. I'm trying to create a page that lists posts from a specific category and then ensure it paginates when they exceed a certain number of posts.

    [code moderated as per Forum Rules - please use the pastebin]

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    you would need a line with query_posts() before the loop;

    http://codex.wordpress.org/Function_Reference/query_posts

    example:

    <?php $args = array(
    'posts_per_page' => 7,
    'category_name' => 'specific',
    'paged' => get_query_var('paged')
    );
    query_posts( $args ); ?>

    for more parameter, see:
    http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
    http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
    http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

  3. Spencer Hill
    Member
    Posted 3 years ago #

    Excellent, that resolved the issue. I think I just had my codex docs mixed up. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.