Show list of categories even if they have no posts

admin2025-06-04  0

Is there a way to show a list of all categories available even if there are no posts associated with them. So if there is a post in that category then it echos a link and if not it just echos out the name of the category?

I'm using wp_list_categories() to show them...

Is there a way to show a list of all categories available even if there are no posts associated with them. So if there is a post in that category then it echos a link and if not it just echos out the name of the category?

I'm using wp_list_categories() to show them...

Share Improve this question asked May 14, 2011 at 13:30 benhowdle89benhowdle89 3212 gold badges5 silver badges11 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 6

There's an argument called hide_empty which is true by default.

$args = array('hide_empty' => FALSE);
wp_list_categories($args);

Codex: wp_list_categories()

Actually hide_empty needed a numerical value for me so

'hide_empty' =>0

worked for me

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748995164a315466.html

最新回复(0)