the_taxonomies( array $args = array() )

Displays the taxonomies of a post with available options.


Description

This function 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.


Top ↑

Parameters

$args array Optional
Arguments about which post to use and how to format the output. Shares all of the arguments supported by get_the_taxonomies() , in addition to the following.
  • postint|WP_Post
    Post ID or object to get taxonomies of. Default current post.
  • beforestring
    Displays before the taxonomies. Default empty string.
  • sepstring
    Separates each taxonomy. Default is a space.
  • afterstring
    Displays after the taxonomies. Default empty string.
More Arguments from get_the_taxonomies( ... $args ) Arguments about how to format the list of taxonomies.
  • templatestring
    Template for displaying a taxonomy label and list of terms.
    Default is "Label: Terms."
  • term_templatestring
    Template for displaying a single term in the list. Default is the term name linked to its archive.

Default: array()


Top ↑

Source

File: wp-includes/taxonomy.php. View all references

function the_taxonomies( $args = array() ) {
	$defaults = array(
		'post'   => 0,
		'before' => '',
		'sep'    => ' ',
		'after'  => '',
	);

	$parsed_args = wp_parse_args( $args, $defaults );

	echo $parsed_args['before'] . implode( $parsed_args['sep'], get_the_taxonomies( $parsed_args['post'], $parsed_args ) ) . $parsed_args['after'];
}


Top ↑

Changelog

Changelog
Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Joy

    This can be used in a theme to support all taxonomies easily.

    <footer class="entry-footer">
    <?php the_taxonomies( array(
    			'before' => '<div class="tax-link-wrap">',
    			'template' => '<span class="taxonomy-label">%s:</span> <span class="taxonomy-term-list">%l.</span>',
    			'term_template' => '<a href="%1$s" rel="tag">%2$s</a>',
    			'sep' => '<br />',
    			'after' => '</div>',
    		) ); ?>
    </footer>

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