WordPress Categories Template Tag - dummies

WordPress Categories Template Tag

WordPress lets you create categories and assign posts to a specific category (or multiple categories). Categories provide an organized navigation system that helps you and your visitors find posts you’ve made on certain topics.

The <?php wp_list_categories(); ?> template tag lets you display a list of your categories by using the available parameters and values. The table shows some of the most popular parameters. Each category is linked to the appropriate category page that lists all the posts you’ve assigned to it. The values that appear in bold are the default values set by WordPress.

Most Common Parameters (Query-String) for wp_list_categories();
Parameter and Type Possible Values Example
Determines how the category list will be ordered.
id; name; slug; count <?php wp_list_categories(orderby=name); ?>
Displays the list of categories by name, alphabetically, as they
appear in the Dashboard.
Determines the order of category list.
ASC (ascending); DESC (descending) <?php wp_list_categories(order=DESC); ?>
Displays categories in descending order.
Determines the format of the category list display.
list; none <?php wp_list_categories (style=list); ?>
Displays the list of category links in which each link is
surrounded by the <li> </li>
HTML tags.
<?php wp_list_categories(style=none); ?>
Displays the list of category links with a simple line break after
each link.
Determines whether to display the post count for each listed
true or 1; false or 0 <?php wp_list_categories(show_count=1); ?>
Displays the post count, in parentheses, after each category list.
Espresso (10), for example, means that
there are ten posts in the Espresso category.
hide_empty (Boolean)
Determines whether categories with no posts assigned to them should
display in the list.
true or 1; false or
<?php wp_list_categories(hide_empty=0); ?>
Displays only those categories that currently have posts assigned
to them.
Determines whether the RSS feed should display for each category in
the list.
rss; default is no feeds
<?php wp_list_categories(feed=rss); ?>
Displays category titles with an RSS link next to each one.
Provides the path/filename for an image for the feed.
No default <?php wp_list_categories(feed_image=/wp-content/images/feed.gif); ?>
Displays the feed.gif image for each
category title. This image is linked to the RSS feed for that
hierarchical (Boolean)
Determines whether the child categories should display after each
parent category in the category link list.
true or 1; false or
<?php wp_list_categories(hierarchical=0); ?>
Doesn’t display the child categories after each parent category in
the category list.

Here are a couple examples of tags used to display a list of your categories.

This example, with its parameters, displays a list of categories sorted by name without showing the number of posts made in each category; it also displays the RSS feed for each category title:

<?php wp_list_categories('orderby=name&show_count=0&feed=RSS'); ?>

This example, with its parameters, displays a list of categories sorted by name with the post count showing; it also shows the subcategories of every parent category:

<?php wp_list_categories('orderby=name&show_count=1&hierarchical=1'); '>