Wordpress Code & Research

Icon

All things about wordpress

Get taxonomy in wordpress

Today, I post about the way to get taxonomy in wordpress:
1-Get the taxonomy name by query_var

$the_tax = get_taxonomy( get_query_var( ‘taxonomy’ ) );
echo $the_tax->labels->name;

Get

if (is_archive())
{
if(is_tax(‘destination’))
{
$term = get_term_by( ‘slug’, get_query_var( ‘term’ ),            get_query_var( ‘taxonomy’ ) );

Get the description:
echo $term->description);

or use this:

$description = explode(“|”, $term->description);
$dest1= $description[0];
echo $dest1;
}
}

Advertisements

Filed under: BASIC CODE, , ,