How to Show the Current Taxonomy Title, URL, and more in WordPress

Not too long ago one among our customers reported a difficulty with their theme. That they had a share button on all pages together with the archive pages. Nonetheless, the taxonomy archive web page share buttons had been displaying the data of the latest publish as a substitute of the particular taxonomy archive. We took a take a look at their code simply to seek out out that they had been calling the_permalink(); and the_title(); tag that are reserved for posts not archive pages. On this article, we are going to present you tips on how to get the present taxonomy title, url, and different info on the particular taxonomy archive web page.

All it’s important to do is paste the next code in your taxonomy archive web page.

$time period = get_term_by( 'slug', get_query_var( 'time period' ), get_query_var( 'taxonomy' ) );

This will get the data of the present taxonomy based mostly on the archive web page you might be on. For instance, when you had been on a class web page referred to as “enterprise”, then it can get the data for that taxonomy.

After that line of code, you need to use it to show the title of the taxonomy and different information like this:

echo $time period->title; // will present the title
echo $time period->slug; // will present the slug

You should use it for the the entire following values:

  • term_id
  • title
  • slug
  • term_group
  • term_taxonomy_id
  • taxonomy
  • description
  • mother or father
  • depend

We hope that this may assist different theme designers who would possibly want this. It might probably come in useful to point out the present taxonomy title or any of the opposite info.

Download The WPSaviour App Now

Related posts
Beginner’s GuideBlog

How to Create Your Own Customized Short URL for Your Blog

Leave a Reply

Your email address will not be published.

Pay in your preferred currency
Indian rupee