Support » Themes and Templates » 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

    (@whooami)

    Member

    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.

    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

    (@whooami)

    Member

    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

    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

    (@whooami)

    Member

    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.