WordPress V2.xTemplate Tag Reference Guide as of Version 2.x
Presented by:
Category Tags
Post Categorythe_category();
Displays a link to the category or categories a post belongs to. This tag must be used within The Loop.
<?php the_category('arguments'); ?>
seperator
Text or character to display between each category link. The default is to place the links in an unordered list.
<?php the_category('seperator=•'); ?>
String
parents
How to display links that reside in child (sub) categories.
<?php the_category('parents=multiple'); ?>
Single
Multiple
Post Category in RSS Formatthe_category_rss();
Displays the name of the category or categories a post belongs to in RSS format. This tag must be used within The Loop.
<?php the_category_rss('arguments'); ?>
type
The type of feed to display to.
<?php the_category_rss('type=rss'); ?>
RSS
RDF
Page Category Titlesingle_cat_title();
Displays or returns the category title for the current page. For pages displaying WordPress tags rather than categories (e.g. "/tag/geek") the name of the tag is displayed instead of the category.
<?php single_cat_title('prefix', 'display'); ?>
prefix
Text to output before the category title. Defaults to '' (no text).
<?php single_cat_title('•','display'); ?>
String
display
Display the category's title
<?php single_cat_title('prefix','TRUE'); ?>
TRUE
FALSE
Category Descriptioncategory_description();
Displays or returns the category title for the current page. For pages displaying WordPress tags rather than categories (e.g. "/tag/geek") the name of the tag is displayed instead of the category.
<?php category_description(category); ?>
category
Returns the description of a category
<?php category_description('2'); ?>
Integer
Category Dropdownwp_dropdown_categories('arguments');
Displays a list of categories in a select (i.e dropdown) box with no submit button.
<?php wp_dropdown_categories('arguments'); ?>
show_option_all
Causes the HTML for the dropdown to allow you to select All of the categories.
<?php wp_dropdown_categories('show_option_all='); ?>
String
show_option_none
Causes the HTML for the dropdown to allow you to select NONE of the categories.
<?php wp_dropdown_categories('show_option_none='); ?>
String
orderby
Key to sort options by.
<?php wp_dropdown_categories('orderby=name'); ?>
ID
name
order
Sort order for options.
<?php wp_dropdown_categories('order=DESC'); ?>
ASC
DESC
show_last_update
Sets whether to display the date of the last post in each category.
<?php wp_dropdown_categories('show_last_update=1'); ?>
1 (true)
0 (false)
show_count
Sets whether to display a count of posts in each category.
<?php wp_dropdown_categories('show_count=1'); ?>
1 (true)
0 (false)
hide_empty
Sets whether to hide (not display) categories with no posts.
<?php wp_dropdown_categories('hide_empty=0'); ?>
1 (true)
0 (false)
child_of
Only display categories that are children of the category identified by its ID. There is no default for this parameter.
<?php wp_dropdown_categories('child_of=5'); ?>
Integer
exclude
Comma separated list of category IDs to exclude. For example, 'exclude=4,12' means category IDs 4 and 12 will NOT be displayed/echoed or returned. Defaults to exclude nothing.
<?php wp_dropdown_categories('exclude=5'); ?>
Integer
echo
Display bookmarks (TRUE) or return them for use by PHP (FALSE).
<?php wp_dropdown_categories('echo=0'); ?>
1 (true)
0 (false)
selected
Category ID of the category to be 'selected' or presented in the display box. Defaults to no category selected.
<?php wp_dropdown_categories('selected=5'); ?>
Integer
heirarchial
Display categories in hierarchical fashion (child categories show indented).
<?php wp_dropdown_categories('heirarchial=1'); ?>
1 (true)
0 (false)
name
Name assigned to the dropdown form. Defaults to 'cat'.
<?php wp_dropdown_categories('name=cat-dropdown'); ?>
String
class
Class assinged to the dropdown form. Defaults to 'postform'.
<?php wp_dropdown_categories('class=cat-dropdown'); ?>
String
depth
This parameter controls how many levels in the hierarchy of Categories are to be included in the list of Categories.
<?php wp_dropdown_categories('depth=n'); ?>
0
-1
1
n
Category Link Listwp_list_categories();
The template tag, wp_list_categories, displays a list of Categories as links. When a Category link is clicked, all the posts in that Category will display on a Category Page using the appropriate Category Template dictated by the Template Hierarchy rules.
<?php wp_list_categories('arguments'); ?>
show_option_all
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.
<?php wp_list_categories('show_option_all='); ?>
String
orderby
Sort categories alphabetically, by unique Category ID, or by the count of posts in that Category. The default is sort by category name.
<?php wp_list_categories('orderby=count'); ?>
ID
name
count
order
Sort order for categories (either ascending or descending).
<?php wp_list_categories('order=DESC'); ?>
ASC
DESC
show_last_updated
Should the last updated timestamp for posts be displayed (TRUE) or not (FALSE).
<?php wp_list_categories('show_last_updated=1'); ?>
1 (true)
0 (false)
style
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 tags).
<?php wp_list_categories('style=none'); ?>
List
None
show_count
Toggles the display of the current count of posts in each category.
<?php wp_list_categories('show_count=1'); ?>
1 (true)
0 (false)
hide_empty
Toggles the display of categories with no posts.
<?php wp_list_categories('hide_empty=0'); ?>
1 (true)
0 (false)
use_desc_for_title
Sets whether a category's description is inserted into the title attribute of the links created
<?php wp_list_categories('use_desc_for_title=0'); ?>
1 (true)
0 (false)
child_of
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.
<?php wp_list_categories('child_of=5'); ?>
Integer
feed
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.
<?php wp_list_categories('feed=RSS'); ?>
String
feed_image
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.
<?php wp_list_categories('feed_images=images/picture.jpg'); ?>
String
exclude
Exclude one or more categories from the results. This parameter takes a comma-separated list of categories by unique ID, in ascending order.
<?php wp_list_categories('exclude=5'); ?>
Integer
include
Only include the categories detailed in a comma-separated list by unique ID, in ascending order.
<?php wp_list_categories('include=5'); ?>
Integer
heirarchial
Display sub-categories as inner list items (below the parent list item) or inline.
<?php wp_list_categories('heirarchial=0'); ?>
1 (true)
0 (false)
title_li
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.
<?php wp_list_categories('titleli=_cats'); ?>
String
number
Sets the number of Categories to display. This causes the SQL LIMIT value to be defined. Default to no LIMIT.
<?php wp_list_categories('number=7'); ?>
Integer
echo
Show the result or keep it in a variable.
<?php wp_list_categories('echo=0'); ?>
1 (true)
0 (false)
depth
This parameter controls how many levels in the hierarchy of Categories are to be included in the list of Categories.
<?php wp_dropdown_categories('depth=n'); ?>
0
-1
1
n
If In Categoryin_category();
Returns true if the current post is in the specified Category. Normally this tag is used within The Loop, but the $post variable must be set when using this tag outside of the loop.
<?php if ( in_category('category_id') ): ?>
// Some category specific PHP/HTML here
<?php endif; ?>
category_id
The category ID of the category for which you wish to test. The parameter may either be passed as a bare integer or as a string
<?php if (in_category('6')): ?>
// Some category specific PHP/HTML here
<?php endif; ?>
Integer
Category's Parents Listget_category_parents();
Returns a list of the parents of a category, including the category, sorted by ID.
<?php echo(get_category_parents(category, display link, separator, nice name)); ?>
category
The numeric category ID for which to return the parents. Defaults to current category, if one is set.
<?php echo(get_category_parents(3, display link, separator, nice name)); ?>
Integer
display link
Creates a link to each category displayed.
<?php echo(get_category_parents(category, TRUE, separator, nice name)); ?>
TRUE
FALSE
seperator
What to separate each category by.
<?php echo(get_category_parents(category, display link, &;bull;, nice name)); ?>
Integer
nice name
Return category nice name or not
<?php echo(get_category_parents(category, display link, seperator, TRUE)); ?>
TRUE
FALSE
Category Arrayget_the_category();
Returns an array of objects, one object for each category assigned to the post. This tag must be used within The Loop.
<?php foreach((get_the_category()) as $category) {
echo $category->cat_name . ' ';
}
?>