Updated October 2026 by Marius: rewritten for current WordPress and tested on WordPress 7.1. Originally published by Hardeep Asrani in 2014.
On a category, tag or custom taxonomy archive page you often need the current term’s link, name or description, for a breadcrumb, a “view all” button or a canonical link. WordPress already knows which term the archive is for. You only need to ask for it.
Get the term link on the archive page
On any taxonomy archive, get_queried_object() returns the current term as a WP_Term object, and get_term_link() turns it into a URL. Put this in your archive template, for example taxonomy.php, taxonomy-{taxonomy}.php or archive.php:
<?php
$term = get_queried_object();
if ( $term instanceof WP_Term ) {
$link = get_term_link( $term );
if ( ! is_wp_error( $link ) ) {
echo '<a href="' . esc_url( $link ) . '">' . esc_html( $term->name ) . '</a>';
}
}
?>Code language: HTML, XML (xml)
The instanceof check keeps the code safe if the template is also used for date or author archives, where the queried object is not a term. get_term_link() returns a WP_Error rather than a URL when something is wrong, which is why its result is checked before use.
Get the term name and description
For the name and description you don’t need the object at all. WordPress has template tags for both:
<h1><?php single_term_title(); ?></h1>
<?php echo term_description(); ?>Code language: HTML, XML (xml)
Show each post’s terms in the loop
If you need the term links for each post on the archive, rather than for the archive itself, use the_terms() inside the loop. Replace genre with your taxonomy’s name:
<?php the_terms( get_the_ID(), 'genre', 'Genre: ', ', ' ); ?>Code language: HTML, XML (xml)
It prints the post’s terms as links, separated by commas. get_the_term_list() takes the same arguments and returns the HTML instead of printing it.
On a block theme
If your site uses a block theme, you may not need any PHP. In the Site Editor, the archive template’s Archive Title block shows the current term, and inside a Query Loop the Post Terms block lists each post’s terms as links. Pick your custom taxonomy in its settings.
