Title: the_terms
Published: April 25, 2014
Last modified: August 20, 2026

---

# the_terms( int $post_id, string $taxonomy, string $before = '', string $sep = ', ', string $after = '' ): void|false

## In this article

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

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

Displays the terms for a post in a list.

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

 `$post_id`intrequired

Post ID.

`$taxonomy`stringrequired

Taxonomy name.

`$before`stringoptional

String to use before the terms.

Default:`''`

`$sep`stringoptional

String to use between the terms. Default ‘, ‘.

Default:`', '`

`$after`stringoptional

String to use after the terms.

Default:`''`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/the_terms/?output_format=md#return)󠁿

 void|false Void on success, false on failure.

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

    ```php
    function the_terms( $post_id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
    	$term_list = get_the_term_list( $post_id, $taxonomy, $before, $sep, $after );

    	if ( is_wp_error( $term_list ) ) {
    		return false;
    	}

    	/**
    	 * Filters the list of terms to display.
    	 *
    	 * @since 2.9.0
    	 *
    	 * @param string $term_list List of terms to display.
    	 * @param string $taxonomy  The taxonomy name.
    	 * @param string $before    String to use before the terms.
    	 * @param string $sep       String to use between the terms.
    	 * @param string $after     String to use after the terms.
    	 */
    	echo apply_filters( 'the_terms', $term_list, $taxonomy, $before, $sep, $after );
    }
    ```

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

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/the_terms/?output_format=md#hooks)󠁿

 [apply_filters( ‘the_terms’, string $term_list, string $taxonomy, string $before, string $sep, string $after )](https://developer.wordpress.org/reference/hooks/the_terms/)

Filters the list of terms to display.

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

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

Retrieves a post’s terms as a list with specified format.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/the_terms/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/the_terms/?output_format=md#)

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

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

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

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/the_terms/?output_format=md#comment-content-575)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_terms/#comment-575)
 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_terms%2F%23comment-575)
     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_terms%2F%23comment-575)
 4.  **Get Categories of Current Post**
      Get a list of current post’s categories:
 5.      ```php
         <?php the_terms( $post->ID, 'category', 'categories: ', ' / ' ); ?>
         ```
     
 6.  The output of the above code could be: categories: TV / Speaker / Monitor
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_terms%2F%3Freplytocom%3D575%23feedback-editor-575)
 8.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/the_terms/?output_format=md#comment-content-2052)
 9.    [Wilgax](https://profiles.wordpress.org/wilgax/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/the_terms/#comment-2052)
 10. [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_terms%2F%23comment-2052)
     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_terms%2F%23comment-2052)
 11. I just wanted to add that the above piece of code will output the categories as
     href links.
 12. **E.g.** Output of the code:
 13.     ```php
         <?php the_terms( $post->ID, 'category', 'categories: ', ' / ' ); ?>
         ```
     
 14. will be in the form:
      `categories: [TV](http://example.com/category/tv) / [Speaker](http://example.com/category/speaker)/
     [Monitor](http://example.com/category/monitor)`
 15.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_terms%2F%3Freplytocom%3D2052%23feedback-editor-2052)

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