WordPress.org

Ready to get started?Download WordPress

Forums

If is tag... (5 posts)

  1. 11Mystics
    Member
    Posted 6 years ago #

    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.

  2. Darran
    Member
    Posted 6 years ago #

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

  3. 11Mystics
    Member
    Posted 6 years ago #

    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.

  4. spencerp
    Member
    Posted 6 years ago #

    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.

  5. Darran
    Member
    Posted 6 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic