How to Show Only Parent Category list in your WordPress
I have been working on my client project with manipulating to show only parent category in footer section , so I’m just search in wordpress docs and google, but I have not found any good tutorial or example.
It is tough work, when it comes to manipulating categories, especially when it comes to identifying the difference between a “Parent” and “Child” category.
WordPress have a “depth” parameter, which allows you to pull out ONLY parent or child categories. However, it still isn’t flexible enough because you can only use it with limited functions.
Here is Code:
<ul><li><?php wp_list_categories('orderby=order&title_li=&depth=1'); ?></li></ul>
The above code will list all parent categories as a link in a list format.
Now this will let you display only the parent category in your footer.
For example see the image in the example:
But if that is all you’re after, that’s cool. But If you want more flexibility with categories, that won’t help.
I hope that’s been useful. 🙂