Simple plugin to display categories in any post or page with a shortcode.
Simple plugin to display categories in any post or page with a shortcode. It’s basically a shortcode API interface to the wp_list_categories WordPress function. This means given any of the parameters accepted by the function, you can pass it in as a shortcode parameter to the categories
shortcode.
Usage:
[categories orderby=count]
Will display links to all the categories and order them by number of posts in each category.
You can also list tags or any other WordPress taxonomy. You need to pass a value to the taxonomy
parameter. For example to list tags: [categories taxonomy=post_tag title_li="Tags"]
.
By default, the usage shows:
See wp_list_categories for usage.
Taken from the wp_list_categories official documentation.
By default, wp_list_categories() generates nested unordered lists (ul) within a single list item (li) titled “Categories”.
You can remove the outermost item and list by setting the title_li parameter to an empty string. You’ll need to wrap the output in an ordered list (ol) or unordered list yourself (see the examples above). If you don’t want list output at all, set the style parameter to none.
You can style the output with these CSS selectors :
li.categories { ... } /* outermost list item */ li.cat-item { ... } li.cat-item-7 { ... } /* category ID #7, etc */ li.current-cat { ... } li.current-cat-parent { ... } ul.children { ... }
For outputting the list into columns, you can use CSS’s multicolumns. Since by default the list is printed as an unordered list with the “categories” class, you can add this to your CSS:
.categories{ column-count: 5; column-gap: 50px; }