wordpress - Limit category depth to parent level -


there's couple of problems need solved here.

1) can't seem list parent categories.

2) there way can show number of trashed posts next echo $live_posts

<ul> <?php     $categories = get_categories();     foreach ($categories $cat) {          $posts = new wp_query( array(      'depth'  => 1,     'post_status' => array('publish'),      'cat' => $cat->cat_id));      $live_posts = $posts->post_count; ?>     <li>         <a href="#"><?php echo $cat->cat_name; ?> (<?php echo $live_posts; ?>)</a>     </li> <?php } ?> </ul> 

regarding first problem, thought 'depth' => 1 supposed limit parents, reasons unknown it's not working. unless i'm missing obvious?

thanks in advance!

$args = array(     'taxonomy' => 'category',     'orderby' => 'name',     'order' => 'asc',     'parent' => 0,     'hide_empty' => false, ); $the_query = new wp_term_query($args); $categories = $the_query->get_terms(); print_r($the_query); exit; 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -