• Resolved estr

    (@estr)


    Hello,

    I have created the following PHP snippets:

    [snip1] = <?php if (is_single()) { ?>
    [snip2] = <?php } ?>

    And put the following into a post:

    [snip1]
    <p>Don’t display this at home/front.</p>
    [snip2]

    But apparently this does not work.

    The text inside <p></p> is different for each post, so ultimately I would like to edit it in a post itself, rather then creating a unique snippet for each post.

    Could this be achieved?

    Thank you!

    http://ww.wp.xz.cn/plugins/post-snippets/

Viewing 1 replies (of 1 total)
  • Hi,

    A shortcode is evaluated per shortcode, so spreading a condition over two shortcodes wont work. But you can probably achive what you want using one shortcode php snippet and the content variable available for snippets:

    snippet:

    if (is_single()) {
    echo "{content}";
    }

    WordPress Post

    [snippet}
    Lorem Ipsum
    [/snippet]

    Cheers,
    Johan

Viewing 1 replies (of 1 total)

The topic ‘Tricky PHP’ is closed to new replies.