So on my wordpress install. I am trying to display category list in the sidebar but having issue with wp_list_categories function. There are handful of categories in the system but this function just prints "NO Categories".
Can't figure out why.
Any ideas?
You're using the right function, but you need to adjust a parameter for it. You are getting
simply because the categories defined in the WordPress taxonomy have no posts assigned to them.
Try passing the
hide_empty
argument towp_list_categories( $args );
1 for true and 0 for false.This example will show all categories regardless of their post count.
Reference the wp_list_categories Codex page for more help.
Make sure you have at least 1 Post in every category you want to display
wp_list_categories
should be outside of the wordpress LOOP. You'll probably need to provide the sidebar's code before the LOOP's code.to use inside loop, use
get_posts()
instead ofget_categories()
;