Support » Fixing WordPress » Displaying posts from specific categories on index prevents browsing by category

  • Resolved sqlu

    (@sqlu)


    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!

Viewing 1 replies (of 1 total)
  • 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. 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying posts from specific categories on index prevents browsing by category’ is closed to new replies.