Title: if Shortcode is???
Last modified: September 1, 2016

---

# if Shortcode is???

 *  Resolved [RE20](https://wordpress.org/support/users/re20/)
 * (@re20)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/if-shortcode-is/)
 * Hi,
    Trying to write an IF statement based on the value of a shortcode. Any ideas?

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 10 months ago](https://wordpress.org/support/topic/if-shortcode-is/#post-7589571)
 * are you putting the “if” inside the code or what? Please explain your use case.
 *  Thread Starter [RE20](https://wordpress.org/support/users/re20/)
 * (@re20)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/if-shortcode-is/#post-7589704)
 * sorry, that would have been a smart idea from the beginning. I’m using custompress
   from wpmu dev, and one of the custom fields I setup is a radio button. and here
   is the PHP shortcode they provide `<?php echo do_shortcode('[ct id="_ct_checkbox_578e5d6304573"
   property="title | description | value"]'); ?>`
 * The value it will spit out will either be YouTube or Vimeo and I’m trying make
   the shortcode an IF state so IF value is youtube show this and IF value is vimeo
   show this.
 * Hope this helps. Thanks
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 10 months ago](https://wordpress.org/support/topic/if-shortcode-is/#post-7589708)
 * A shortcode returns a string, so you can look at that string in your code and
   modify it via str_replace() or a more fancy regex based replace. If that’s what
   you want to do, I’d use
 * `$field = do_shortcode( '[whatever]' );`
 * then do what needs to be done with `$field` and echo that result.
 *  Thread Starter [RE20](https://wordpress.org/support/users/re20/)
 * (@re20)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/if-shortcode-is/#post-7589713)
 * Ok great thanks. now i need to figure out how to get if $field equals A show 
   this else show b. Thoughts
 *  Thread Starter [RE20](https://wordpress.org/support/users/re20/)
 * (@re20)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/if-shortcode-is/#post-7589716)
 * NEVER MIND I GOT IT
 *     ```
       <?php
       $field = do_shortcode('[yadayda]');
   
       if($field !== 'A') {
   
           echo $field;
   
       } else {
   
           echo 'B';
   
       }
        ?>
       </div>
       ```
   

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

The topic ‘if Shortcode is???’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [RE20](https://wordpress.org/support/users/re20/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/if-shortcode-is/#post-7589716)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
