Adding custom taxonomy title to archive/search pages in WordPress

Needed this for my custom taxonomy for code snippets, when navigating via the tags of my non-regular taxonomy/category terms.

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

I stuck this in to my ‘archive.php’ file in my theme (after line 30)

<?php } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h1>Blog Archives</h1>
<?php } else { $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); // HACKED in for custom taxonomy titles.?>
<h1>Posts Tagged &quot;<?php echo $term->name;?>&quot;</h1>
<?php } ?>

Note it just has an ‘else’ at the end since I don’t know what it should be specifically – may cause problems down the line but seems OK for now.

SeeĀ http://stackoverflow.com/questions/2805879/wordpress-taxonomy-title-output

Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑