Forums

Starting The Loop, For Just a Specific Category (3 posts)

  1. Smoolean
    Member
    Posted 2 years ago #

    Hi everyone,

    I've heard that there is a plugin that allows you to control which categories are shown on your homepage. That's not exactly what I'm looking for.

    I'm asking, in the code sense, where would you define that you only want a specific category to be looped through and displayed.

    I want a certain category to display in the sidebar (their title, content, everything) and am not sure how to achieve this?

    I'm guessing that there is a parameter that you can add to one of the following tags, but I wasn't able to find it in the codex/docs.

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    Any help will be greatly appreciated.

  2. Otto42
    Moderator
    Posted 2 years ago #

    Start here:
    http://codex.wordpress.org/The_Loop#Multiple_Loops

    Look at all those examples, especially the ones involving new WP_Query... and you'll see how to write a Loop in the sidebar that won't interfere with your main page.

    Then notice that you can pass cat=number to the WP_Query to get a specific category number.

  3. Smoolean
    Member
    Posted 2 years ago #

    Awesome, thank you so much Otto42! That was exactly what I was looking for!

Topic Closed

This topic has been closed to new replies.

About this Topic