Title: the_category
Published: April 25, 2014
Last modified: February 24, 2026

---

# the_category( string $separator, string $parents, int|false $post_id = false )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#wp--skip-link--target)

Displays category list for a post in either HTML list or custom format.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#parameters)󠁿

 `$separator`stringoptional

Separator between the categories. By default, the links are placed in an unordered
list. An empty string will result in the default behavior.

`$parents`stringoptional

How to display the parents. Accepts `'multiple'`, `'single'`, or empty.
 Default
empty string.

`$post_id`int|falseoptional

ID of the post to retrieve categories for. Defaults to the current post.

Default:`false`

## 󠀁[Source](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#source)󠁿

    ```php
    function the_category( $separator = '', $parents = '', $post_id = false ) {
    	echo get_the_category_list( $separator, $parents, $post_id );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/category-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/category-template.php#L276)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/category-template.php#L276-L278)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#related)󠁿

| Uses | Description | 
| [get_the_category_list()](https://developer.wordpress.org/reference/functions/get_the_category_list/)`wp-includes/category-template.php` |

Retrieves category list for a post in either HTML list or custom format.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 6 content](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#comment-content-430)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_category/#comment-430)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-430)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-430)
 4.  **Separated by Space**
      List categories with a space as the separator.
 5.      ```php
         <?php the_category( ' ' ); ?>
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%3Freplytocom%3D430%23feedback-editor-430)
 7.   [Skip to note 7 content](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#comment-content-1813)
 8.    [oliverdrummond](https://profiles.wordpress.org/oliverdrummond/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/the_category/#comment-1813)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-1813)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-1813)
 10. **$parents**
      　▪ ‘multiple’ – Display separate links to parent and child categories,
     exhibiting “parent/child” relationship. (Exhibiting the parents and child with
     links pointing for both) 　▪ ‘single’ – Display link to child category only, with
     link text exhibiting “parent/child” relationship. (Exhibiting the parents and 
     child but the link points only to the child category)
 11.  * $parents is stated as defaulting to empty string, without an indication of 
        whether this will be interpreted as ‘multiple’ or ‘single’.
      * [douglasuk](https://profiles.wordpress.org/douglasuk/) [6 years ago](https://developer.wordpress.org/reference/functions/the_category/#comment-3515)
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%3Freplytocom%3D1813%23feedback-editor-1813)
 13.  [Skip to note 8 content](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#comment-content-431)
 14.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_category/#comment-431)
 15. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-431)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-431)
 16. **Separated by Comma**
      Displays links to categories, each category separated 
     by a comma (if more than one).
 17.     ```php
         <?php the_category( ', ' ); ?>
         ```
     
 18.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%3Freplytocom%3D431%23feedback-editor-431)
 19.  [Skip to note 9 content](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#comment-content-432)
 20.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_category/#comment-432)
 21. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-432)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-432)
 22. **Separated by Arrow**
      Displays links to categories with an arrow (>) separating
     the categories. _Note:_ Take care when using this, since some viewers may interpret
     a category following a > as a subcategory of the one preceding it.
 23.     ```php
         <?php the_category( '&gt; ' ); ?>
         ```
     
 24.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%3Freplytocom%3D432%23feedback-editor-432)
 25.  [Skip to note 10 content](https://developer.wordpress.org/reference/functions/the_category/?output_format=md#comment-content-433)
 26.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_category/#comment-433)
 27. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-433)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%23comment-433)
 28. **Separated by a Bullet**
      Displays links to categories with a bullet (•) separating
     the categories.
 29.     ```php
         <?php the_category( '&bull;' ); ?>
         ```
     
 30.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F%3Freplytocom%3D433%23feedback-editor-433)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category%2F)
before being able to contribute a note or feedback.