Include the Taxonomy name on Archive pages


I am looking for a solution to include a txonomy term on the archive pages such as

Currently these use the default index.php page and have the static code:

<div class="main_category_title">
<h1>Category: <?php single_cat_title(); ?></h1>

1. I would like to find a way to replace the static word "Category: " with the taxonomy name. In this example "Calories: "

2. I am using the same index.php page for blog post and my new content type of Walks.

How do I get my new Content Type of "Walks" to use its own index file? What do i need to name it?

(I am using a child theme for all these changes)

Many thanks

  • Michael Bissett
    • Recruit

    Hey @chris, hope you're doing well today. :slight_smile:

    1. You can try inserting this after get_header:

    <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>

    And then replace "Category" with this:

    <?php echo $term->name; ?>


    How do I get my new Content Type of "Walks" to use its own index file? What do i need to name it?

    Are you wanting an index file (template) for single posts, or for archives? It looks like you've already got a "single" template for the "Walks" template?

    Please advise,

  • chris
    • The Crimson Coder

    Hi Michael,

    That code replaced Category: with a duplicate of the Term name. (same as <?php single_cat_title(); ?>

    I need it to identify the taxonomy name (Duration, Distance, Calories, Amenities etc)

    Any ideas?

    As for the custom template it is needed for the archive.

    I have a custom single_walk.php template for individual walks but I wanted something for archives for the taxonomies that are used only for walks.

    So for example my taxonomines of distance, duration, calories and amenities are only used for the content type Walks.

    It may be possible to get away without using a custom archive template page for this job - but i have some other site i was hoping to completely customise the archive pages of the custompress new content types.


  • Ash
    • WordPress Hacker

    Hi @chris

    I hope you are well today.

    Would you please try the following instead of $term->name?
    <?php echo $term->taxonomy; ?>

    About the custom template, is "Walks" a custom post type? Then you can create your custom template based on this post type:

    For single: single-walks.php
    For archive: archive-walks.php

    If it is a custom taxonomy: taxonomy-walks.php

    If it is a tag: tag-walks.php

    Hope it helps :slight_smile: Please feel free to ask more question if you have.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.