$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Show list of categories even if they have no posts|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Show list of categories even if they have no posts

matteradmin7PV0评论

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

Post a comment

comment list (0)

  1. No comments so far