Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

do not bring child post WordPress

  • SOLVED

Hi

I would like my category listing page not to show child category post of the parent.

If a parent category is selected the page should show post that are directly assigned to this parent category

Answers (3)

2011-03-07

S├ębastien | French WordpressDesigner answers:

Simply
query_posts(array('category__in' => $cat));
in category.php, before the loop = before "while"

or if you use a theme with a file loop.php
in category.php, before get_template_part( 'loop',

2011-03-06

Vidyut Kale answers:

making any category negative in query posts will not return posts from it.


$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1,-3 );
$myposts = get_posts( $args );


Vidyut Kale comments:

Try


$category = get_category($cat);
query_posts(array('category__in' => array($category)));


Vidyut Kale comments:

Sent that by mistake.

Basically, try using 'category__in' instead of 'category'.

2011-03-07

Ivaylo Draganov answers:

Hello,

try placing this before your category loop:

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$current_cat = get_query_var('cat');
$args=array(
'category__in' => array($current_cat),
'paged' => $paged
);
query_posts($args);
?>


Also, check out this post for some more details:
[[LINK href="http://www.kristarella.com/2010/03/23/wordpress-exclude-child-categories-from-category-archives/"]]http://www.kristarella.com/2010/03/23/wordpress-exclude-child-categories-from-category-archives/[[/LINK]]