WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to display a post where a category is..... (3 posts)

  1. roscoek
    Member
    Posted 4 years ago #

    I know this has got to be a fairly common question which I could not find the solution. I have categories called, Home, About, Sponsor, and so on. So, each page of the site, has a category.

    I only want posts under Home to be on the home, post with category About, to be under the about page. You get it.

    So, on my home page, index.php, how can I say where only posts with a category of 35 to show. Here are the first lines of code where I think if I can add to the conditon if(have_post) I could also add and where category is 35.

    How do I add that condition?


    <?php get_header(); ?>

    <!-- START LOOP -->
    <div id="content" class="widecolumn">
    <?php if (have_posts()) : ?>

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

  2. MichaelH
    Member
    Posted 4 years ago #

    <?php
    query_posts('cat=35');
    if (have_posts()) : ?>

    See The Loop article for more examples.

    Related plugin: http://wordpress.org/extend/plugins/simply-exclude/

    Related:
    Conditional Tags
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

  3. roscoek
    Member
    Posted 4 years ago #

    Thanks Michael it worked.

Topic Closed

This topic has been closed to new replies.

About this Topic