Title: PHP is_single in post?
Last modified: August 18, 2016

---

# PHP is_single in post?

 *  [teccus](https://wordpress.org/support/users/teccus/)
 * (@teccus)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/php-is_single-in-post/)
 * Is there anyway I can use code like this is my post?
 * <?php
    if (is_single()) { echo ‘<img src=\”test.jpg\” alt=\”Test Image\” />’;}?
   >
 * Because at the moment it’s not allowing me too.

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

 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/php-is_single-in-post/#post-427336)
 * you want the code to execute or just be displayed? your question isnt clear?
 * You cannot simply paste php, (or any language for that matter) into a post, especially
   if you want it to be executed.
 *  Thread Starter [teccus](https://wordpress.org/support/users/teccus/)
 * (@teccus)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/php-is_single-in-post/#post-427339)
 * Well I want that image from that post to be displayed only if it is on the single.
   php…
 * So eg..
 * Text text text
 * <display pic if is single.php
 * Text text text
 * Why can’t I use php in my post?
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/php-is_single-in-post/#post-427341)
 * _Why can’t I use php in my post?_
 * Because its not “safe” for starters. Because the wp devs care. Doesnt really 
   matter.
 * The solution is easily found though via that magical search function:
 * [http://wordpress.org/search/php+inside+a+post?forums=1](http://wordpress.org/search/php+inside+a+post?forums=1)
 *  Thread Starter [teccus](https://wordpress.org/support/users/teccus/)
 * (@teccus)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/php-is_single-in-post/#post-427342)
 * Yes the search function is magical. But none of those posts solve my problem.
   The plugins only allow ‘Echo’..
 * They don’t allow me to do if(is_single()), do they..
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/php-is_single-in-post/#post-427354)
 * I reckon if you cannot find a plugin that works than youre left to code your 
   own plugin, ask someone else to write you a plugin, or find another way to accomplish
   whatever it is you’re trying to do.

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

The topic ‘PHP is_single in post?’ is closed to new replies.

## Tags

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

 * 5 replies
 * 2 participants
 * Last reply from: [whooami](https://wordpress.org/support/users/whooami/)
 * Last activity: [19 years, 10 months ago](https://wordpress.org/support/topic/php-is_single-in-post/#post-427354)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
