Forums

[resolved] Placing Posts on Certain Pages by Category (3 posts)

  1. Davebenroberts
    Member
    Posted 1 month ago #

    I have a 6 page wordpress site, that I will have 6 different Categories of Posts. I need Category number one to show up on Page number one, Category number two to show up on page number two.

    I'd like to be able to show the posts through the plug-in Visual Recent Posts

    Any Information on this would help. I'm thinking possibly an If else statement?

    Similar to:

    `$body = 'b';
    if (is_page('about')) {
    $body = 'body-0';
    } elseif (is_page('destinations')) {`

    Thanks in Advance!

    -Dave

  2. MichaelH
    moderator
    Posted 1 month ago #

    Don't really know why you would need Pages to display a set of posts belonging to a category. The WordPress native archiving ability will handle that for you.

    If you are using Pages because of a nav bar situation, then look at How to easily display links to both Pages and Categories in the blog navigation header?

    Related:
    Category Templates

  3. tugbucket
    Member
    Posted 1 month ago #

    <?php if ( is_page('page1') ) { ?>
    <?php query_posts('category_name=page1'); ?>
    <?php } ?>
    
    <?php if ( is_page('page2') ) { ?>
    <?php query_posts('category_name=page2'); ?>
    <?php } ?>
    
    <?php if ( is_page('page3') ) { ?>
    <?php query_posts('category_name=page3'); ?>
    <?php } ?>
    
    <!-- start the loop -->
    <?php while (have_posts()) : the_post(); ?>
    <!-- your loop -->
    <?php endwhile;?>

Reply

You must log in to post.

About this Topic