WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Displaying posts from specific categories on index prevents browsing by category (2 posts)

  1. sqlu
    Member
    Posted 3 years ago #

    On my main index template (index.php), I have the following bit of code to restrict the categories that are displayed to just my blog, updates, and uncategorized posts:

    <?php query_posts('cat=1,3,15'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    However, when I try to browse by category, all the category pages show only those posts, as well, and don't let me access the other posts.

    Is there some piece of code that I need to put elsewhere or modify in order to be able to show only those categories on the homepage, but allow browsing by categories? Thanks!

  2. sqlu
    Member
    Posted 3 years ago #

    Nevermind, I figured out what piece of code I needed to add. In order to get this behavior to apply only on the home page, I had to use a conditional tag:

    <?php if (is_home()) {query_posts('cat=1,3,15');}; ?>

    Now it's working perfectly. :)

Topic Closed

This topic has been closed to new replies.

About this Topic