Installing and Configuring the WordPress.com Stats Plugin
How to Preview and Activate WordPress.com Themes
How to View the Template Files in a WordPress Theme

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
orderby
(string)
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.
order
(string)
Determines the order of category list.
ASC (ascending); DESC (descending) <?php wp_list_categories('order=DESC'); ?>
Displays categories in descending order.
style
(string)
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.
show_count
(Boolean)
Determines whether to display the post count for each listed category.
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 0 <?php wp_list_categories('hide_empty=0'); ?>
Displays only those categories that currently have posts assigned to them.
feed
(string)
Determines whether the RSS feed should display for each category in the list.
rss; default is no feeds display <?php wp_list_categories('feed=rss'); ?>
Displays category titles with an RSS link next to each one.
feed_image
(string)
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 category.
hierarchical (Boolean)
Determines whether the child categories should display after each parent category in the category link list.
true or 1; false or 0 <?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'); '>
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
The Layout and Structure of the WordPress Twenty Twelve Theme
How to Add WordPress Widgets to Sidebars or Footers
How to Upload a New WordPress Plugin
How to Install a WordPress Theme
How to Install WordPress Plugins within the Dashboard
Advertisement

Inside Dummies.com