• I am trying to display all posts in a category, without showing the posts in child categories of the parent. https://testing.wearewireless.com under products it shows posts that are in phones which is a sub of products, how do I stop children form showing? Below is my index page:

    ‘<?php get_header(); ?>

    <!– *** –><div class=”clear”></div><!– *** –>

    <!– Main Content START –>
    <div class=”fwGrid-8″>
    <div id=”mainContent” class=”fwVer-10″>

    <!– Featured Post START –>
    <?php if($paged==0){include(TEMPLATEPATH.”/featuredpost.php”); } ?>
    <!– Featured Post END –>

    <?php
    if(get_category($sst_settings[‘sst_news_cat’]))
    $query_cat = ‘category_name=’.get_category($sst_settings[‘sst_news_cat’])->category_nicename.’&’;
    ?>

    <?php query_posts($query_cat.’showposts=’.get_option(‘sst_news_nr_home’).’&paged=’.$paged);

    if(have_posts()) : while(have_posts()) : the_post();
    if ($post->ID != $featured_ID) { ?>

    <div class=”block”>
    <?php if (get_post_meta($post->ID, ‘image_thumb’, true)) { ?>
    <div class=”fwLeft newsImg”>
    “><img src=”<?php echo get_post_meta($post->ID, ‘image_thumb’, true); ?>” alt=”” class=”fwBorder” />
    </div>

    <div class=”newsContent”>
    <?php } ?>

    <h1>” title=”<?php the_title(); ?>”><?php the_title(); ?></h1>

    <?php if(get_option(‘sst_news_date’) || get_option(‘sst_news_cats’) || get_option(‘sst_news_author’)) { ?>
    <small>Posted <?php if(get_option(‘sst_news_date’)) { ?>on <?php the_time(‘M d’); } ?> <?php if(get_option(‘sst_news_cats’)) { ?> in <?php the_category(‘, ‘); } ?> <?php if(get_option(‘sst_news_author’)) { ?> by <?php the_author_posts_link(); } ?></small><?php } ?>

    <?php the_content(‘Read More’); ?> <div class=”separator biggap”></div>

    <?php if (get_post_meta($post->ID, ‘image_thumb’, true)) { ?>
    </div>
    <?php } ?>

    <div class=”clear”></div>
    <div class=”blockFooter”>
    <?php if(get_option(‘sst_news_comments’)) { ?>
    “>Leave a response<span class=”sep”> </span>“><?php comments_number(); ?>
    <?php } ?>
    </div>

    <!– *** –><div class=”clear”></div><!– *** –>
    </div>

    <?php } endwhile ?>

    <div id=”posts_navigation”>
    <div class=”alignleft”><?php previous_posts_link() ?></div>
    <div class=”alignright”><?php next_posts_link() ?></div>
    </div>
    <!– *** –><div class=”clear”></div><!– *** –>

    <?php else : ?>
    <h2 class=”center”>Not Found</h2>
    <p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
    <?php endif; ?>

    </div>
    </div>
    <div class=”fwGrid-4″>
    <div id=”sidebar”>
    <!– Sidebar START –>
    <?php get_sidebar(); ?>
    <!– Sidebar END –>
    </div>
    </div>
    <!– Main Content END –>

    <!– *** –><div class=”clear”></div><!– *** –>

    <?php get_footer(); ?>’

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter rankspace

    (@rankspace)

    Does anyone know where this particular depth is set?

    Don’t think there is a ‘depth’ argument with query_posts. Probably going to have to get a list (array) of the child category IDs and then use the category__not_in clause with query_posts.

    Just as a note, ANY category that has been designated a Parent category is not meant to be checked in the category hierarchy when writing posts. Meaning, only the latest generation category should be checked. Think of it like this, only the youngest generation gets the action.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show Category Posts Without Children’ is closed to new replies.