I need to display the name of a custom taxonomy term in a page template, and I've tried with the following line:
<h2><?php the_terms( 0, 'my_category'); ?></h2>
This correctly retrieves the taxonomy and displays the desired term, but it also adds a link to that term archive page.
I'd like to display only a simple text, with no link at all.
How should I modify this?
To give more context:
<?php
$args = array(
'post_type' => 'my_post_type',
'tax_query' => array(
array(
'taxonomy' => 'my_category',
'field' => 'slug',
'terms' => 'my_term',
),
),
);
$my_query = new WP_Query( $args );
?>
<div>
<h2><?php the_terms( 0, 'my_category'); ?></h2>
</div>
<?php
while ( $my_query->have_posts() ) :
$my_query->the_post();
?>
<div>
<h3><?php the_title(); ?></h3>
<div><?php the_content(); ?></div>
</div>
<?php
endwhile;
wp_reset_query();
wp_reset_postdata();
?>