WordPress at Your Fingertips

the_taxonomies() WP 1.0

Display the taxonomies of a post with available options.

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.

1 time — 0.009228 sec (very slow) | 50000 times — 51.10 sec (very slow) | PHP 7.1.2, WP 4.7.3

No Hooks.

Return

null. Nothing.

Usage

the_taxonomies( $args );
$args(array)

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.

  • int|WP_Post()
    $post Post ID or object to get taxonomies of.
    Default: current post

  • string()
    $after Displays after the taxonomies.
    Default: empty string

Changelog

Since 2.5.0 Introduced.

Code of the_taxonomies() WP 5.7.2

<?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'];
}

From category: For posts

More from Template Tags: Taxonomies (category, tag)

No comments
    Log In