Support » Themes and Templates » To show just parent category posts and no others!!

  • Resolved Kresimir Pendic

    (@gorostas)


    Hi, I have this loop in my category-7.php

    I would like to return just parent category posts, and this below is my code which is broken..

    this function ‘post_is_in_descendant_category’ is in my theme folder ‘functions.php’, and I copied it from here http://codex.wordpress.org/Function_Reference/in_category

    <?php if (have_posts()) : ?>
    
    	<?php while (have_posts()) : the_post();
            if ( in_category(7) && post_is_in_descendant_category(7) ) {
        ?>
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    
    			<div class="post-headline">
    				<h2>
    					<a href="<?php the_permalink() ?>" rel="bookmark" title="stalni link na <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    				</h2>
    			</div>
    		    <div class="post-byline"><?php the_time("F jS, Y") ?> - <?php the_author() ?></div>
    			<div class="post-bodycopy clearfix">
    				<?php if the_content(" .. opširnije &raquo;"); ?>
    			</div>
    		</div>
    
    	<?php } ?>
    	<?php endwhile; ?>
    
    <?php if ( is_single() ) { comments_template(); } ?>
    
    <?php else : ?>
    
    	<h2 class="center">Ups..</h2>
    	<p class="center">sorry, izgleda da nisam nasao sta trazis.</p>
    	<?php get_search_form(); ?>
    
    <?php endif; ?>

    thanks ..

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘To show just parent category posts and no others!!’ is closed to new replies.