Method a:
wp_list_categories().
Usage
 <?php wp_list_cats(‘arguments’); ?>Â
Examples
Default Usage
By default, the tag:
optionall – Does not display a link to all Categories
all – Text to display for link to all Categories
sort_column – Sorts by Category ID
sort_order – Sorts in ascending order
file – Displays the Categories using the index.php template
list – Sets the Categories in an unordered list (<ul><li>)
optioncount – Does not display the count of posts within each Category
hide_empty – Does not display links to Categories which have no posts
use_desc_for_title – Uses the Category description as the link title
children – Shows the children (sub-Categories) of every Category listed
hierarchical – Displays the children Categories in a hierarchical order under its Category parent
examples:
<div class=’sidebarbox’>
           <h3>Categories 1</h3>
           <ul>Â
               <?php wp_list_cats(‘sort_column=name’); ?>   Â
           </ul>
       </div>
Method b:
<?php wp_list_categories(‘arguments’); ?>Â
Parameters
show_option_all
(string) A non-blank values causes the display of a link to all categories if the style is set to list. The default value is not to display a link to all.
orderby
(string) Sort categories alphabetically, by unique Category ID, or by the count of posts in that Category. The default is sort by category name. Valid values:
ID
name – default
count
order
(string) Sort order for categories (either ascending or descending). The default is ascending. Valid values:
ASC – default
DESC
show_last_updated
(boolean) Should the last updated timestamp for posts be displayed (TRUE) or not (FALSE). Defaults to FALSE.
* 1 (true)
* 0 (false) – default
style
(string) Style to display the categories list in. A value of list displays the categories as list items while none generates no special display method (the list items are separated by <br> tags). The default setting is list (creates list items for an unordered list). See the markup section for more. Valid values:
list – default.
none
show_count
(boolean) Toggles the display of the current count of posts in each category. The default is false (do not show post counts). Valid values:
1 (true)
0 (false) – default
hide_empty
(boolean) Toggles the display of categories with no posts. The default is true (hide empty categories). Valid values:
1 (true) – default
0 (false)
use_desc_for_title
(boolean) Sets whether a category’s description is inserted into the title attribute of the links created (i.e. <a title=”<em>Category Description</em>” href=”…). The default is true (category descriptions will be inserted). Valid values:
1 (true) – default
0 (false)
child_of
(integer) Only display categories that are children of the category identified by this parameter. There is no default for this parameter. If the parameter is used, the hide_empty parameter is set to false.
feed (string)
Display a link to each category’s rss-2 feed and set the link text to display. The default is no text and no feed displayed.
feed_image
(string) Set a URI for an image (usually an rss feed icon) to act as a link to each categories’ rss-2 feed. This parameter overrides the feed parameter. There is no default for this parameter.
exclude
(string) Exclude one or more categories from the results. This parameter takes a comma-separated list of categories by unique ID, in ascending order. See the example. The child_of parameter is automatically set to false.
include
(string) Only include the categories detailed in a comma-separated list by unique ID, in ascending order. See the example.
hierarchical
(boolean) Display sub-categories as inner list items (below the parent list item) or inline. The default is true (display sub-categories below the parent list item). Valid values:
1 (true) – default
0 (false)
title_li
(string) Set the title and style of the outer list item. Defaults to “_Categories”. If present but empty, the outer list item will not be displayed. See below for examples.
number
(integer) Sets the number of Categories to display. This causes the SQL LIMIT value to be defined. Default to no LIMIT.
echo
(boolean) Show the result or keep it in a variable. The default is true (display the categories organized). Valid values:
1 (true) – default
0 (false)
depth
(integer) This parameter controls how many levels in the hierarchy of Categories are to be included in the list of Categories. The default value is 0 (display all Categories and their children). This parameter added at Version 2.5
0 – All Categories and child Categories (Default).
-1 – All Categories displayed in flat (no indent) form (overrides hierarchical).
1 – Show only top level Categories
n – Value of n (some number) specifies the depth (or level) to descend in displaying Categories
current_category
(integer) Allows you to force the “current-cat” to appear on uses of wp_list_categories that are not on category archive pages. Normally, the current-cat is set only on category archive pages. If you have another use for it, or want to force it to highlight a different category, this overrides what the function thinks the “current” category is.
example:
<div class=’sidebarbox’>
<h3>Categories 3</h3>
<ul>
<?php wp_list_categories(‘exclude=1,6&title_li=’); ?>
</ul>
</div>