Grow your CSS skills. Land your dream job.

[Solved] WordPress – Output Posts from Specific Category

  • # November 2, 2009 at 4:57 am

    Gday, I am trying to get wordpress to only output posts from a certain category on the front page of my new website. Does anyone know how to adjust the below code to achieve this?

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

    Many thanks.

    Rob
    # November 2, 2009 at 10:07 am

    Yup – its all in here :)

    http://codex.wordpress.org/The_Loop

    :D

    # November 2, 2009 at 1:35 pm

    More specifically, you’re looking for the query_posts function:

    http://codex.wordpress.org/Template_Tags/query_posts

    # November 4, 2009 at 6:51 am

    Thank you….but unfortunately my php skills are a little scarce.

    Currently the code on my wordpress index.php is -

    Code:
    < ?php if (have_posts()) : ?>

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

    < ?php endif; ?>

    And from the wordpress Codex I have established that I need to implement:

    Code:
    query_posts(‘cat=1′);

    However I’m clueless as to how to include this into my existing code… :?:

    Any further help would be appreciated :)

    # November 4, 2009 at 9:45 am

    Just change the line that opens up the loop to this:

    Code:
    < ?php query_posts('cat=1'); if (have_posts()) : ?>
    # November 4, 2009 at 5:40 pm

    Fantastic! Thank you Chris :)

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".