clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

Get custom taxonomy term name on an archive page on WordPress

Filed under: WordPress— Tagged with: custom taxonomy, term

How to retrieve the term’s name when rendering a custom taxonomy route.

If you’re viewing a normal Post category rendered via archive.php template, then you can use single_cat_title() function to display the current category name. But when dealing with custom taxonomies it’s a bit different.

And it is as simple as:

$tax = $wp_query->get_queried_object();
echo $tax->name

Comments would go here, but the commenting system isn’t ready yet, sorry. Tweet me @hiljaa if you want to make a correction etc.

  • © 2021 Antti Hiljá
  • About
  • Follow me in Twatter → @hiljaa
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • console.log('Smash the patriarchy!')
  • I love u!