Wordpress sidebar issue with wp_list_categories showing NO categories

So, on my Wordpress installation. I am trying to display a list of categories in the sidebar, but there is a problem with the wp_list_categories function. There are several categories in the system, but this function simply prints "NO Categories".

I can’t understand why.

Any ideas?

0
source share
3 answers
  • Make sure you have at least 1 post in each category that you want to display.

  • wp_list_categoriesmust be outside wordpress LOOP. You will probably need to specify the sidebar code before the LOOP code.

0
source

, .

, , WordPress, , .

hide_empty wp_list_categories( $args ); 1 true 0 false.

wp_list_categories('hide_empty=0');

.

wp_list_categories Codex.

0

get_posts() get_categories();

$cat_ID = 239;

$array =  get_posts('child_of'=> $cat_ID ,    'post_type'=> 'post');    $out='';
foreach ($array as $key=> $value) {
    $out .= '<li class="manual_posts"><a href="'.get_permalink($value->ID).'">'.$value->post_title.'</a></li>';
}
echo $out;
0

Source: https://habr.com/ru/post/1766785/


All Articles