Title: has_tag with array conditional tag PHP question please
Last modified: August 19, 2016

---

# has_tag with array conditional tag PHP question please

 *  [slobizman](https://wordpress.org/support/users/slobizman/)
 * (@slobizman)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/has_tag-with-array-conditional-tag-php-question-please/)
 * I’m trying to condition some ads based upon tags. I do it in several functions,
   so I want to define the array of tags I’m referencing just once.
 * So I am doing this first:
 * `$noadtags = array('tag1','tag2','tag3');`
 * And the I have an IF statement that checks it. However, it is not working. Can
   someone see what is wrong with my PHP?
 *  `if (!has_tag(array($noadtags))) {`
 * I’ve also tried it like this:
 *  `if (!has_tag(array('$noadtags'))) {`
 * and like this:
 *  `if (!has_tag(($noadtags))) {`
 * and this:
 *  `if (!has_tag(('$noadtags'))) {`

Viewing 1 replies (of 1 total)

 *  [DigitalSquid](https://wordpress.org/support/users/twelvefootsnowman/)
 * (@twelvefootsnowman)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/has_tag-with-array-conditional-tag-php-question-please/#post-1624263)
 * The 3rd example you posted should work fine. You’ve got a few too many brackets
   in the code but that shouldn’t stop it working:
 *     ```
       $noadtags = array('tag1','tag2','tag3');
       if(!has_tag($noadtags)){
       	// Do Something
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘has_tag with array conditional tag PHP question please’ is closed to 
new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 2 participants
 * Last reply from: [DigitalSquid](https://wordpress.org/support/users/twelvefootsnowman/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/has_tag-with-array-conditional-tag-php-question-please/#post-1624263)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
