WordPress V3.xTemplate Tag Reference Guide as of Version 3.x
Presented by:
Category Tags
Category Descriptioncategory_description();
Returns the description of a category defined in the category settings screen for the current category (Posts > Categories).
<?php echo category_description($category); ?>
$category
Integer • Default: current category
The numeric ID of the category for which the tag is to return the description.
Get the Term Listget_the_term_list();
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. Can be used only outside The Loop.
<?php get_the_term_list($id, $taxonomy, $before, $sep, $after); ?>
$id
Integer • Default: 0
Post ID.
$taxonomy
String/Array • Default: none
Name of taxonomy.
$before
String • Default: none
(Optional) Leading text.
$sep
String • Default: none
(Optional) String to separate tags.
$after
String • Default: none
(Optional) Trailing text.
Single Cat 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. Can be used only outside The Loop.
<?php single_cat_title($prefix, $display); ?>
$prefix
String • Default: ''
(Optional) Text to output before the title.
$display
Boolean • Default: true
(Optional) Should the title be displayed (true) or returned for use in PHP (false).
Single Term Titlesingle_term_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. Can be used only outside The Loop.
<?php single_term_title($prefix, $display); ?>
$prefix
String • Default: ''
(Optional) Text to output before the title.
$display
Boolean • Default: true
(Optional) Should the title be displayed (true) or returned for use in PHP (false).
Term Descriptionterm_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. Can be used only outside The Loop.
<?php single_term_title($term_id, $taxonomy); ?>
$term_id
Integer • Default: ID of current query term
(Optional) The ID of the term to return a description.
$taxonomy
String • Default: 'post_tag'
(Optional) Should the title be displayed (true) or returned for use in PHP (false). Valid values:
- 'category'
- 'post_tag'
- 'link_category'
The 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($separator, $parents, $post_id); ?>
$separator
String • Default: '', which places the links in an unordered list
Text or character to display between each category link.
$parents
String • Default: '', link to the child category, with no relationship exhibited
How to display links that reside in child (sub) categories. Options are:
- 'multiple' - Display separate links to parent and child categories, exhibiting "parent/child" relationship.
- 'single' - Display link to child category only, with link text exhibiting "parent/child" relationship.
Note: Default is a link to the child category, with no relationship exhibited.
$post_id
Integer • Default: 0 (false) which uses the current post
Post ID to retrieve categories.
The Category RSSthe_category_rss();
Display the post categories in the feed.
<?php the_category_rss($type); ?>
$type
String • Default: 'rss'
(Optional) Either 'rss', 'atom', or 'rdf'.
The Taxonomiesthe_taxonomies();
This template tag can be used within The Loop to display the taxonomies for a post without specifying the Post ID. You can also use it outside The Loop to display the taxonomies for a specific post.
$args = array( | ||||
'post' | => | 0, | ||
'before' | => | '', | ||
'sep' | => | '', | ||
'after' | => | '', | ||
'template' | => | '' | ||
); |
<?php the_taxonomies($args); ?>
post
Integer • Default: 0
(Optional) The post ID to get taxonomies of.
before
String • Default: none
(Optional) Display before taxonomies list.
sep
String • Default: none
(Optional) Separate every taxonomy with value in this.
after
String • Default: none
(Optional) Display this after the taxonomies list.
template
String • Default: none
(Optional) Template used to display the taxonomies list.
The Termsthe_terms();
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. Can be used only outside The Loop.
<?php the_terms($id, $taxonomy, $before, $sep, $after); ?>
$id
Integer • Default: 0
Post ID.
$taxonomy
String/Array • Default: none
Name of taxonomy.
$before
String • Default: none
(Optional) Leading text.
$sep
String • Default: none
(Optional) String to separate tags.
$after
String • Default: none
(Optional) Trailing text.
WP Dropdown Categorieswp_dropdown_categories();
Display or retrieve the HTML dropdown list of categories. Arguments are passed in as either an array or a query string.
$args = array( | ||||
'show_option_all' | => | '', | ||
'show_option_none' | => | '', | ||
'orderby' | => | 'ID', | ||
'order' | => | 'ASC', | ||
'show_count' | => | false, | ||
'hide_empty' | => | true, | ||
'child_of' | => | false, | ||
'exclude' | => | '', | ||
'echo' | => | true, | ||
'selected' | => | false, | ||
'hierarchical' | => | false, | ||
'name' | => | 'cat', | ||
'id' | => | '', | ||
'class' | => | 'postform', | ||
'depth' | => | 0, | ||
'tab_index' | => | 0, | ||
'taxonomy' | => | 'catetory', | ||
'hide_if_empty' | => | false | ||
); |
<?php wp_dropdown_categories($args); ?>
show_option_all
String • Default: ''
(Optional) Text to display for showing an 'all categories' option. Default will not show an option to select 'all categories'.
show_option_none
String • Default: ''
(Optional) Text to display for showing a 'no categories' option. Default will not show an option to select 'no categories'.
orderby
String • Default: 'ID'
(Optional) Column name to use for ordering the categories.
order
String • Default: 'ASC'
(Optional) Direction to sort categories. Valid values are 'ASC' and 'DESC'.
show_count
Boolean • Default: false
(Optional) Whether to show the post count in category.
hide_empty
Boolean • Default: true
(Optional) Whether to hide a category with no posts.
child_of
Boolean • Default: false
(Optional) Whether to display all categories that are descendants (i.e. children & grandchildren) of the category identified by its ID. If the parameter is used, the hide_empty parameter is effectively set to false.
exclude
String • Default: ''
(Optional) Category IDs to exclude. This parameter takes a comma-separated list of categories by unique ID, in ascending order.
echo
Boolean • Default: true
(Optional) Send output to browser (true) or return output to PHP (false).
selected
Integer • Default: 0
(Optional) Which category ID is selected.
hierarchical
Boolean • Default: false
(Optional) Display all categories (false) or display categories (true) to a depth of 'depth'.
name
String • Default: 'cat'
(Optional) The 'name' attribute value for select element.
id
String • Default: ''
(Optional) The 'id' attribute value for select element.
class
String • Default: 'postform'
(Optional) The 'class' attribute value for select element.
depth
Integer • Default: 0
(Optional) The max depth. This is ignored unless hierarchical is set to true.
tab_index
Integer • Default: 0
(Optional) The 'tabindex' attribute for the select element.
taxonomy
String • Default: 'category'
(Optional) Taxonomy to return. Valid values are 'category', 'post_tag' or any registered taxonomy.
hide_if_empty
Boolean • Default: false
(Optional) Hide dropdown (true) or show it (false) if no terms returned.
WP List Categorieswp_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. Arguments are passed in as either an array or a query string.
$args = array( | ||||
'show_option_all' | => | '', | ||
'orderby' | => | 'name', | ||
'order' | => | 'ASC', | ||
'style' | => | 'list', | ||
'show_count' | => | false, | ||
'hide_empty' | => | true, | ||
'use_desc_for_title' | => | true, | ||
'child_of' | => | false, | ||
'feed' | => | '', | ||
'feed_type' | => | '', | ||
'feed_image' | => | '', | ||
'exclude' | => | '', | ||
'exclude_tree' | => | '', | ||
'include' | => | '', | ||
'hierarchical' | => | true, | ||
'title_li' | => | __('Categories'), | ||
'show_option_none' | => | __('No categories'), | ||
'number' | => | null, | ||
'echo' | => | true, | ||
'depth' | => | 0, | ||
'current_category' | => | 0, | ||
'pad_counts' | => | 0, | ||
'taxonomy' | => | 'catetory', | ||
'walker' | => | 'Walker_Category' | ||
); |
<?php wp_list_categories($args); ?>
show_option_all
String • Default: ''
(Optional) A non-blank value 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 • Default: 'ID'
(Optional) 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', 'slug', 'count', and 'term_group.'
order
String • Default: 'ASC'
(Optional) Direction to sort categories. Valid values are 'ASC' and 'DESC'.
style
String • Default: 'list'
(Optional) 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). Valid values: 'list' and 'none'.
show_count
Boolean • Default: false
(Optional) Whether to show the post count in category.
hide_empty
Boolean • Default: true
(Optional) Whether to hide a category with no posts.
use_desc_for_title
Boolean • Default: true
(Optional) 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="...).
child_of
Boolean • Default: false
(Optional) Whether to display all categories that are descendants (i.e. children & grandchildren) of the category identified by its ID. If the parameter is used, the hide_empty parameter is effectively set to false.
feed
String • Default: ''
(Optional) 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_type
String • Default: ''
(Optional) The type of feed if one is used.
feed_image
String • Default: ''
(Optional) 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.
exclude
String • Default: ''
(Optional) Category IDs to exclude. This parameter takes a comma-separated list of categories by unique ID, in ascending order. The child_of parameter is automatically set to false.
exclude_tree
String • Default: ''
(Optional) Exclude category-tree from the results.
include
String • Default: ''
(Optional) Only include the categories detailed in a comma-separated list by unique ID, in ascending order.
hierarchical
Boolean • Default: true
(Optional) Display sub-categories as inner list items (below the parent list item)(true), or inline (false).
title_li
String • Default: 'Categories'
(Optional) Set the title and style of the outer list item. If present but empty, the outer list item will not be displayed.
show_option_none
String • Default: ''
(Optional) Text to display for showing a 'no categories' option. Default will not show an option to select 'no categories'.
number
Integer • Default: 0
(Optional) Sets the number of Categories to display. This causes the SQL LIMIT value to be defined. Default to no LIMIT.
echo
Boolean • Default: true
(Optional) Send output to browser (true) or return output to PHP (false).
depth
Integer • Default: 0
(Optional) This parameter controls how many levels in the hierarchy of Categories are to be included in the list of Categories. Possible values and their meanings:
- 0 - All Categories and child Categories
- -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 • Default: 0
(Optional) 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.
pad_counts
Boolean • Default: false
(Optional) Calculates link or post counts by including items from child categories. If show_counts and hierarchical are true this is automatically set to true.
taxonomy
String • Default: 'category'
(Optional) Taxonomy to return. Valid values are 'category', 'post_tag' or any registered taxonomy.
walker
Object • Default: none
(Optional) Walker class to render the list with - and instance of a class that extends either Walker_Category or Walker.