Exclude a category from a query that includes its parent category

First you should move wp_reset_query(); outside of the loop instead of resetting the query every post of the loop. And as for your query you can use category__not_in $args = array( ‘cat’ => 14, ‘category__not_in’ => array(’45’), ‘posts_per_page’ => 20 ); $the_query = new WP_Query($args); while ($the_query->have_posts()) : $the_query->the_post();?> <li> <a href=”https://wordpress.stackexchange.com/questions/17387/<?php the_permalink() ?>” rel=”bookmark” … Read more

query_post order desc

You need to use this to parameters orderby and order <?php query_posts( array( ‘category_name’ => ‘my_category_slug’, ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ‘posts_per_page’ => -1 ) ); ?>

Equivalent to in_category() for subcategories

try this: function is_subcategory($category = null) { if (is_category()) { if (null != $category){ $cat = get_category($category); }else{ $cat = get_category(get_query_var(‘cat’),false); } if ($cat->parent == 0 ){ return false; }else{ return true; } } return false; } Usage: //to check if the current context is a subcagetory: if (is_subcategory()){ //its a subcategory; }else{ //nope is … Read more

How to hide child categories from displaying

wp_list_cats is deprecated. You should switch to the “newer” version wp_list_categories which also supports some additional options. For example the depth option, which is probably what you’re looking for. See the WordPress codex for more information. wp_list_categories(array( ‘style’ => ‘none’, ‘orderby’ => ‘name’, ‘show_count’ => true, ‘hierarchical’ => true, ‘depth’ => 1 ));