WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] What Tag Page am I on? (5 posts)

  1. Chris_K
    Member
    Posted 6 years ago #

    Clicking a tag in 2.3 will take us to a listing of posts for that tag. When I'm on that listing (I'm using tag.php), how do I discern what tag the listing is for? I'd like to include it in my <title>.

    With UTW, I had something like this in my header.php:

    <title>
    	<?php if (is_tag()) { ?>
    		<?php echo 'Articles tagged with: '; ?>
    		<?php UTW_ShowCurrentTagSet('tagsettextonly'); ?>
    		<?php echo ' &raquo; '; ?>
    		<?php bloginfo('name'); ?>
    	<?php } else { ?>
    		<?php wp_title(''); ?>
    		<?php if(wp_title('', false)) { echo ' &raquo; '; } ?>
    		<?php bloginfo('name'); ?>
    	<?php } ?>
    </title>

    Any thoughts on how to replace that UTW_ShowCurrentTagSet() call?

    I guess the same could apply to meta for single pages as well. How to grab these critters out of The_Loop?

  2. MichaelH
    Member
    Posted 6 years ago #

    Try single_tag_title(). No Codex docs at this time.

  3. Chris_K
    Member
    Posted 6 years ago #

    Thanks! That works delightfully.

  4. Chris_K
    Member
    Posted 6 years ago #

    For posterity's sake (and searching since I forget things):

    <title>
    	<?php if (is_tag()) { ?>
    		<?php echo 'Articles tagged with: '; ?>
    		<?php single_tag_title(); ?>
    		<?php echo ' &raquo; '; ?>
    		<?php bloginfo('name'); ?>
    	<?php } else { ?>
    		<?php wp_title(''); ?>
    		<?php if(wp_title('', false)) { echo ' &raquo; '; } ?>
    		<?php bloginfo('name'); ?>
    	<?php } ?>
    </title>
  5. Tobias Jordans
    Member
    Posted 6 years ago #

    Sorry, but this does not solve the problem!

    Unfortunatelly the wp_title(”) only outputs one tag.

    Like URL /tag/foo/ gives the output foo.
    But URL /tag/foo+bar/ also gives only foo.

    So right now there seems to be no propper replacement for UTW_ShowCurrentTagSet

    Any ideas?

    BTW: wp_title() does the same (wrong thing) as single_tag_title()

Topic Closed

This topic has been closed to new replies.

About this Topic