Title: tag makes something happen in single post HOW TO ?
Last modified: August 20, 2016

---

# tag makes something happen in single post HOW TO ?

 *  [ghp123](https://wordpress.org/support/users/ghp123/)
 * (@ghp123)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/)
 * I would like to show different options below my single post when a curtain tag
   is used.
 * for instance if the tag dog is used i would like to make a link to a dog page
 * i thought i could use is_tag but that does not seem to work.
 * Any suggestions?
 * Greetings,
    George

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Jonas Grumby](https://wordpress.org/support/users/ss_minnow/)
 * (@ss_minnow)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/#post-2151135)
 * is_tag is one way to do it. Another way would be to create a template called 
   tag-dog.php.
 *  Thread Starter [ghp123](https://wordpress.org/support/users/ghp123/)
 * (@ghp123)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/#post-2151142)
 * the is_tag does not work is there a reason why it could not work in the single
   post?
 *  [Jonas Grumby](https://wordpress.org/support/users/ss_minnow/)
 * (@ss_minnow)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/#post-2151144)
 * Hard to say since I have no idea what your code looks like. It would probably
   be easier to create a template such as tag-dog.php.
 * [http://codex.wordpress.org/images/1/18/Template_Hierarchy.png](http://codex.wordpress.org/images/1/18/Template_Hierarchy.png)
 *  [datdesignguy](https://wordpress.org/support/users/datdesignguy/)
 * (@datdesignguy)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/#post-2151146)
 * Hi ghp,
 * I think the reason is_tag does not work for you is because that function is intended
   to detect whether or not the page being viewed is an archive page for a specific
   tag/all-tags…
 * In order to achieve what you’re wanting to do, you’ll need to use the `get_the_tags()`
   function and then evaluate whether the desired term is contained in the list 
   of returned tags.
 * You might want to write a custom function in your theme’s functions.php file 
   to handle this. Here is the func ref for `get_the_tags()`:
    [http://codex.wordpress.org/Function_Reference/get_the_tags](http://codex.wordpress.org/Function_Reference/get_the_tags)
 *  Thread Starter [ghp123](https://wordpress.org/support/users/ghp123/)
 * (@ghp123)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/#post-2151147)
 * i tried with this piece of code
 * <?php if (is_tag(‘peep’)) { ?>
    EXTRA INFO
 *  <?php } elseif (is_tag(‘batman’)) { ?>
    BATMAN
 *  <?php } elseif (is_tag(‘lost’)) { ?>
    LOST
 *  <?php } else { ?>
    ELSE
 * <?php } ?>
 * And it just seems to always take the else part.
 * I don’t really know how to do to much in php and you totally lost me with the
   tag-dog.php part as i don’t have a clue how to do something like that
 *  [datdesignguy](https://wordpress.org/support/users/datdesignguy/)
 * (@datdesignguy)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/#post-2151148)
 * ghp, see my earlier post… is_tag() is not intended to be used in the way you 
   are looking for, that’s why you’re only getting the “else” response.
 * you’ll need to use something like this:
 *     ```
       <?php
       $post_tags = get_the_tags();
       $tag_array = array();
       foreach($post_tags as $tag) {
         $tag_array[] = $tag->name;
       }
       if(in_array('dog',$tag_array) !== FALSE) {
       //show dog tag related code
       } else if(in_array('cat',$tag_array) !== FALSE) {
       //show cat tag related code
       } else if(in_array('pig',$tag_array) !== FALSE) {
       //show pig tag related code
       } else {
       //none of your special tags were found
       }
       ?>
       ```
   
 * I haven’t had a chance to test this code as I’ve written it, but that should 
   get you rolling in the right direction. I’ve used this before to show tag-specific
   opt-in forms to readers on a clients blog…
    I hope this helps!
 * -greg
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/#post-2151170)
 * > the is_tag does not work is there a reason
 * as [@datdesignguy](https://wordpress.org/support/users/datdesignguy/) already
   said, `is_tag()` only works to identify a tag archive page;
    to check for tags
   in a post, try `has_tag()` [http://codex.wordpress.org/Function_Reference/has_tag](http://codex.wordpress.org/Function_Reference/has_tag)
 * general [http://codex.wordpress.org/Conditional_Tags](http://codex.wordpress.org/Conditional_Tags)
 * it always makes sense to read the codex 😉
 *  Thread Starter [ghp123](https://wordpress.org/support/users/ghp123/)
 * (@ghp123)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/ta/#post-2151198)
 * Thanks for all the help.
 * The has_tag() seem to do the trick without me making to many changes.
 *  [ddpweb](https://wordpress.org/support/users/ddpweb/)
 * (@ddpweb)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/ta/#post-2151427)
 * Yes! Thank you so much for this thread. The has_tag() is exactly what I was looking
   for.
 *     ```
       <?php if (has_tag(array('video',''))) { ?>
       <!-- don't show the image if there is a video-->
   
       <?php } else { ?>
   
       <div class="featuredImage"> <?php if ( has_post_thumbnail()) the_post_thumbnail(array( 504,378 )); ?> </div>
   
       <?php } ?>
       ```
   

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘tag makes something happen in single post HOW TO ?’ is closed to new 
replies.

## Tags

 * [is_tag](https://wordpress.org/support/topic-tag/is_tag/)
 * [single post](https://wordpress.org/support/topic-tag/single-post/)
 * [tag](https://wordpress.org/support/topic-tag/tag/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 5 participants
 * Last reply from: [ddpweb](https://wordpress.org/support/users/ddpweb/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/ta/#post-2151427)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
