WordPress.org

Support

Support » Themes and Templates » If is tag…

If is tag…

  • 11Mystics
    Member

    @11mystics

    You guys know that great piece of code that’s often in the archive or index.php files goes something like:

    <?php if (is_category()) { ?>
    	<h1>Entries Categorized as <?php echo single_cat_title(); ?></h1>
    
    <?php } elseif (is_author()) { ?>
    	<h1>Author Archive</h1>
    
    <?php } elseif (is_month()) { ?>
    	<h1>Entries from <?php the_time('F Y'); ?></h1>

    This chunk of PHP controls the text that appears at the top of the page in the page heading H1 tag.

    I need to add an “elseif” for when I’m displaying a tag though and I don’t know how to specify that with PHP. When I click on a tag from my tag cloud on my archives page, it launches /index.php?tag=”tagname”.

    If you have the code for this, I’d appreciate it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Darran
    Member

    @darran

    You can use the is_tag() in your conditionals to check for a tag page.

    11Mystics
    Member

    @11mystics

    I’m not using a tag page. The tag cloud is my archives.php template so I need code that will recognize the fact that it’s going to load up using the index.php page.

    spencerp
    Member

    @spencerp

    You mean something like this, that I use in my themes?

    <?php if ( function_exists( 'the_tags' ) ) : the_tags('Tags: ', ', ',
    ''); endif; ?>

    This way I could use that theme on versions under 2.3 and have things still work without problems.. Or, you mean something else?

    EDIT: Nevermind.. I’m behind on sleep here. Sorry. I posted wrong thing for you.

    Darran
    Member

    @darran

    So you want to display your tags when you view archives?

    Why don’t you create an archive template to use in your page?

    Sorry I am not really sure what you are asking, isn’t very clear

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘If is tag…’ is closed to new replies.