the_tags( string $before = null, string $sep = ', ', string $after = '' )

Retrieve the tags for a post.


Description Description


Parameters Parameters

$before

(string) (Optional) Before list.

Default value: null

$sep

(string) (Optional) Separate items using this.

Default value: ', '

$after

(string) (Optional) After list.

Default value: ''


Top ↑

Source Source

File: wp-includes/category-template.php

function the_tags( $before = null, $sep = ', ', $after = '' ) {
	if ( null === $before ) {
		$before = __( 'Tags: ' );
	}

	$the_tags = get_the_tag_list( $before, $sep, $after );

	if ( ! is_wp_error( $the_tags ) ) {
		echo $the_tags;
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Codex

    Default Usage
    The default usage lists tags with each tag (if more than one) separated by a comma (,) and preceded with the default text Tags: .

    <p><?php the_tags(); ?></p>

    Separated by Commas
    Displays a list of the tags with a line break after it.

    <?php the_tags( 'Tags: ', ', ', '<br />' ); ?> 

    Separated by Arrow
    Displays links to tags with an arrow (>) separating the tags and preceded with the text Social tagging:

    <?php the_tags( 'Social tagging: ',' > ' ); ?>

    Separated by a Bullet
    Displays links to tags with a bullet (•) separating the tags and preceded with the text Tagged with: and followed by a line break.

    <?php the_tags( 'Tagged with: ', ' • ', '<br />' ); ?>

    A List Example
    Displays a list of the tags as an unordered list:

    <?php the_tags( '<ul><li>', '</li><li>', '</li></ul>' ); ?>

You must log in before being able to contribute a note or feedback.