WordPress Cheat Sheet / Tags – Part 4 [Category Tags]

Hello friends. Today I want to learn the Category Tags of WordPress theme. Lets start to learn.

Category Description   category_description();

Returns the description of a category defined in the category settings screen for the current category (Posts > Categories).

<?php echo category_description($category); ?>


Type: Integer

The numeric ID of the category for which the tag is to return the description. Defaults to the current category, if one is not set.

Single Cat Title   single_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); ?>


Type: String

(Optional) Text to output before the title.


Type: Boolean

(Optional) Should the title be displayed (True) or returned for use in PHP (False). Default: True.

The Category   the_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); ?>


Type: String

Text or character to display between each category link. The default is to place the links in an unordered list.


Type: String

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.


Type: Integer

Post ID to retrieve categories. The default value is false (the current post).

The Category RSS   the_category_rss();

Display the post categories in the feed.

<?php the_category_rss($type); ?>


Type: String

(Optional) Either ‘rss’, ‘atom’, or ‘rdf’. Default is ‘rss’.

Dropdown Categorieswp_dropdown_categories();

Display or retrieve the HTML dropdown list of categories.

<?php wp_dropdown_categories($args); ?>


Type: String

(Optional) Override default arguments. By default, the usage shows:

<?php $args = array(
‘show_option_all’ => ,
‘show_option_none’ => ,
‘orderby’ => ‘ID’,
‘order’ => ‘ASC’,
‘show_last_update’ => 0,
‘show_count’ => 0,
‘hide_empty’ => 1,
‘child_of’ => 0,
‘exclude’ => ,
‘echo’ => 1,
‘selected’ => 0,
‘hierarchical’ => 0,
‘name’ => ‘cat’,
‘id’ => ,
‘class’ => ‘postform’,
‘depth’ => 0,
‘tab_index’ => 0,
‘taxonomy’ => ‘category’,
‘hide_if_empty’ => false
  • Sorts by category id in ascending order
  • Does not show the last date updated
  • Does not show the count of posts within a category
  • Does not show ’empty’ categories
  • Excludes nothing
  • Displays (echos) the categories
  • No category is ‘selected’ in the form
  • Does not display the categories in a hierarchical structure
  • Assigns ‘cat’ to the form name
  • Assigns the form to the class ‘postform’
  • No select ID so will default to ‘name’
  • Class of postform
  • No depth limit
  • Tab index of 0
  • Use taxonomy = category
  • Hide dropdown if no terms returned

List Categories   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($args); ?>


Type: String

(Optional) Override default arguments. By default, the usage shows:

<?php $args = array(
‘show_option_all’ => ,
‘orderby’ => ‘name’,
‘order’ => ‘ASC’,
‘show_last_update’ => 0,
‘style’ => ‘list’,
‘show_count’ => 0,
‘hide_empty’ => 1,
‘use_desc_for_title’ => 1,
‘child_of’ => 0,
‘feed’ => ,
‘feed_type’ => ,
‘feed_image’ => ,
‘exclude’ => ,
‘exclude_tree’ => ,
‘include’ => ,
‘hierarchical’ => true,
‘title_li’ => __( ‘Categories’ ),
‘number’ => NULL,
‘echo’ => 1,
‘depth’ => 0,
‘current_category’ => 0,
‘pad_counts’ => 0,
‘taxonomy’ => ‘category’,
‘walker’ => ‘Walker_Category’
  • No link to all categories
  • Sorts the list of Categories by the Category name in ascending order
  • Does not show the last update (last updated post in each Category)
  • Displayed in an unordered list style
  • Does not show the post count
  • Displays only Categories with posts
  • Sets the title attribute to the Category Description
  • Is not restricted to the child_of any Category
  • No feed or feed image used
  • Does not exclude any Category and includes all Categories
  • Displays the active Category with the CSS Class-Suffix ‘ current-cat’
  • Shows the Categories in hierarchical indented fashion
  • Display Category as the heading over the list
  • No SQL LIMIT is imposed (‘number’ => 0 is not shown above)
  • Displays (echos) the categories
  • No limit to depth
  • All categories.
  • The list is rendered using the Walker_Category class

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s