List categories

Plugin Banner

List categories

by Fernando Briano

Download
Description

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:

  • No link to all categories
  • Sorts the list of Categories by the Category name in ascending order
  • Displayed in an unordered list style
  • Does not show the post count
  • Displays only Categories with posts
  • Sets the title attribute to the Category Description
  • Is not restricted to the child_of any Category
  • No feed or feed image used
  • Does not exclude any Category and includes all Categories
  • Displays the active Category with the CSS Class-Suffix ‘ current-cat’
  • Shows the Categories in hierarchical indented fashion
  • Display Category as the heading over the list
  • No SQL LIMIT is imposed (‘number’ => 0 is not shown above)
  • Displays (echos) the categories
  • No limit to depth
  • All categories.
  • The list is rendered using a new walker object of the the Walker_Category class

See wp_list_categories for usage.

Markup and Styling of Category Lists

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 instance, you can remove the bullet points next to each category with:

.cat-item {
  list-style-type: none
}

Show categories list in columns

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;
}
  • Upload the plugin’s directory into your wp-content/plugins/ directory.
  • Login to your WordPress Admin menu, go to Plugins, and activate it.

Simple, but effective

By amedeebulle on July 24, 2023

I was looking for a way to list subcategories of a single main category.
This plugin does the trick (and more)

Easy and useful

By robegb on May 25, 2023

Well documented. Thank you!

Just what I needed

By Chris Roberts (artcop1) on October 6, 2022

Thank you for the great plugin! It works perfectly with WP v6.0.2 and my Hello Theme and has saved me hours of work 🙂 Cheers!

Thank you!!

By bigcheesez on October 2, 2022

i hope these great works bless you with future work and good fortune. thank you kindly. oh and i tested this and works fine!

not to use

By orangesunshine on March 30, 2018

could not find out out how to use it.

Works as promised

By Mel - Jett Web Development (MelR) on November 16, 2016

Thank you, perfect solution in minutes!

Working

By Mohsin Alam (mohsinworld) on September 3, 2016

This plugin only working, it has no styling. I would love to have some style like grid system and two column. Thanks

Best Plugin

By Mojtaba Faal (MojtabaFaal) on September 3, 2016

Best Plugin

Elegantly Written

By AJ Mallory (JasonM4563) on September 3, 2016

Thanks for publishing this little plugin. I ended up taking the code and integrating it into a custom solution but the plugin is well put together and pretty powerful.

Some better docs would help make it more useful for folks.

Thanks for making this available!

Works as described. Could use better documentation.

By pwil30 on September 3, 2016

Works a charm, and was especially useful for me as Insert PHP had a conflict with my theme and/or Visual Composer.

Only thing is I had to fish around for awhile to figure out how to put in multiple parameters, as the plugin author doesn't describe how to do this -- and it is NOT the exact same as wp_list_categories.

For example:
wp_list_categories code:
<?php wp_list_categories('orderby=name&title_li=' ?>

This plugin requires a space between parameters rather than ampersand:
[categories orderby=name title_li='']

It would be helpful if the developer adds this to the documentation to save users some time. But overall, the plugin is much appreciated!

0.4

  • Tested up to the latest version of WordPress.

0.3

  • Tested up to the latest version of WordPress
  • Adds note about taxonomies, updates parameters

0.2

  • Fixes plugin content with wrong placement. Thanks windwww from the WP Forums.

0.1

Back to top