Forums

Help me show post navigation inside a category loop (2 posts)

  1. ldexterldesign
    Member
    Posted 2 years ago #

    Hi guys,

    I have this piece of code pumping out a category loop on one of my WP pages (blog page):

    <?php // if blog page
    if(is_page('9')){ ?>
    <?php // pull in desired category post content
    $lastposts = get_posts('numberposts=10&category=19');
    foreach($lastposts as $post) : setup_postdata($post); ?>
    <h2>" id="post-<?php the_ID(); ?>">
    <?php the_title(); ?>
    </h2>
    <?php the_content(); ?>
    <p class="postmetadata">
    <?php the_tags('Tags: ', ', ', '
    '); ?>
    Posted in
    <?php the_category(', ') ?>
    |
    <?php edit_post_link('Edit', '', ' | '); ?>
    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    </p>
    <?php endforeach;
    } ?>

    My only issue with the code is that I don't get posts navigation now in order to navigate to older posts and back again, since my numberposts=10 parameter limit is 10.

    Could anyone help me modify the above so it allows my users to navigate to older posts and back again? The only solution I have right now is to display infinite posts (not very scalable :[ )

    Thanks in advance,
    L

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    I wonder if using the technique described in How to easily display links to both Pages and Categories in the blog navigation header? would be easier:

    To display a link to your News Category along with the other Pages in your navigation header, install a plugin such as Page Links To, create a Page called News, then in the Page Links To module, in the "Point to this URL:" field, enter the URL for the News category. Note: to determine the URL for the News Category, just visit that Category in your blog and copy the URL in your browser address bar.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.