1

i am using wp_list_categories('child_of=54&title_li=') method to display all the subcategories, but it is showing only one, how can i use it with loop to show all the subcategories properly.

4
  • 1
    That works for me. Do the missing subcategories have posts? By default the categories without posts are hidden, but you can add &hide_empty=0 to change that.
    – Gabriel
    Aug 22, 2014 at 15:09
  • yes i have added the posts, actually i want to display the subcategories using loop. Aug 22, 2014 at 15:23
  • i am giving solution of my own question, <?php $descendant=array('child_of'=>54)?> <?php $categories = get_categories($descendant);?> <?php foreach($categories as $category) :?> <?php echo $category->name;?> <?php endforeach;?> Aug 25, 2014 at 10:46
  • @PieterGoosen, if my answer is correct, you can vote it too :) Sep 17, 2014 at 13:21

1 Answer 1

2

I am giving solution of my own problem :)

<?php 
$descendant= array('child_of'=>54);
$categories = get_categories($descendant);
foreach($categories as $category) :
    echo $category->name;
endforeach;
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.