How to exclude Child Category
-
Hi folks,
My website has 4 parent categories. On my homepage I show the latest posts of every one of these categories. Here’s the code I use for this:
<?php $categories=array( 'include' => '24,19,13,5', 'orderby' => 'name', 'order' => 'ASC' ); $categories=get_categories($categories); foreach($categories as $category) { $post_args=array( 'showposts' => 1, // you can fetch number of articles from each category 'category__in' => array($category->term_id), 'caller_get_posts'=> 1 ); $posts=get_posts($post_args); if ($posts) { echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> '; foreach($posts as $post) { setup_postdata($post); ?> <div id="latest" > <p id="home-excerpt-title" ><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?></a></p> <p id="home-excerpt-image" ><?php the_excerpt(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Lees verder <?php the_title_attribute();?>"> Lees verder <span class:"meta-nav">→</span></a> </div> <?php } // foreach($posts } // if ($posts } // foreach($categories ?>
Now this all works good, but how can I exclude a category? I want to exclude 1 child category of one of these parent categories because I would like to display it somewhere else on my page.
I’ve tried to fool around in the code to get this but since I’m kinda new to all this maybe I’m not doing the right things ??
Thanks for your help
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to exclude Child Category’ is closed to new replies.