Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to display the current archives name, so for the url below I could do something like this

<h1><?php echo "answer" ?></h1>

which would output something like this

<h1>News</h1>

or better yet

<h1>News: supplierName</h1>

http://www.site.com/suppliers/news/?supplierstax=supplierName

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

This is probably what you need:

<?php if (is_category()) { // Show only on Category archive pages ?>
<h1><?php echo single_cat_title('News: '); ?></h1>

<?php } elseif (is_tag()) { // Show only on Tag archive pages ?>
<h1><?php echo single_tag_title('News: '); ?></h1>

<?php } ?>

OR like this (as @StephenHarris pointed out):

<h1><?php
    if ( is_category() || is_tag() ) {
        single_term_title( 'News: ', false );
    }
?></h1>
share|improve this answer
2  
See inside wp_title (see source) for similar functions. Many take a prefix as an argument, e.g. 'News: ' in the OP's question. –  Stephen Harris Jun 29 '12 at 14:08
    
Yup - but I was just linking there in case others need to find a similar function for a different context :) –  Stephen Harris Jun 29 '12 at 14:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.