the_taxonomies() WordPress Function

The the_taxonomies() function is used to list all taxonomies for a given post.

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.

  • 'post'
    (int|WP_Post) Post ID or object to get taxonomies of. Default current post.
  • 'before'
    (string) Displays before the taxonomies. Default empty string.
  • 'sep'
    (string) Separates each taxonomy. Default is a space.
  • 'after'
    (string) Displays after the taxonomies. Default empty string.

Default value: array()


Top ↑

Source

File: wp-includes/taxonomy.php

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
VersionDescription
2.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More