tags:

views:

20

answers:

1

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

A: 

Hey Done by doing this

<?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);
                            echo '<ul>';
                            foreach ($cat_child as $category) {
                                 $cat_id = intval($category->term_id);
                                 echo '<li>';
                                    echo get_category_parents($cat_id , TRUE , ' <br/> ');
                                 echo '</li>';
                            }
                            echo '</ul>';
                     ?>

Thank you

saorabh