Snippets

Daniel Shaw Get a list of tags by ID and taxonomy.

Created by Daniel Shaw
/**
 * Get a list of tags by ID and taxonomy.
 *
 * @since 1.0.0
 *
 * @param Array  $scope    The list of term IDs to filter against.
 * @param String $taxonomy The taxonomy name.
 */
function chthnc_get_tags_by_term( $scope, $taxonomy ) {
	$scope = array_unique( $scope );
	$scope = implode( ',', $scope );

	$args = array(
		'include'   => $scope,
		'taxonomy'  => $taxonomy,
		'smallest'  => 1,
		'largest'   => 1,
		'unit'      => 'em',
		'number'    => 0,
		'format'    => 'list',
		'separator' => null,
		'orderby'   => 'name',
		'order'     => 'ASC',
		'echo'      => true,
	);

	wp_tag_cloud( $args );
}

add_action( 'get_tags_by_term', 'chthnc_get_tags_by_term', 10, 2 );

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.