Display Wordpress parent Category with their child category

Posted by saorabh on Stack Overflow See other posts from Stack Overflow or by saorabh
Published on 2010-06-11T09:06:52Z Indexed on 2010/06/11 9:13 UTC
Read the original article Hit count: 254

Filed under:

Hi,

I want to display only those the parent category which have some child category with their child category without using child_of=

I was trying to display but i am only able to get the list of child category not their parent category name.

<?php

$querystr = "SELECT wp_terms.name, wp_terms.term_id, wp_terms.name FROM wp_terms, wp_term_taxonomy WHERE wp_terms.term_id = wp_term_taxonomy.term_id AND wp_term_taxonomy.parent !=0 ";
$cat_child = $wpdb->get_results($querystr, OBJECT);
var_dump($cat_child);
foreach ($cat_child as $category) {
         echo $category->name. ' , ';
      }
  ?>

Help me.. Thanks

© Stack Overflow or respective owner

Related posts about Wordpress