Displaying Shortcodes

Have you ever wanted to display a shortcode in a post? i.e. like this: [gallery]

It’s actually quite simple thanks to a little-known feature of WordPress. All you need to do is double up on the brackets:

[[gallery]]
[[example]foobar[/example]]

Note where the double brackets are in that last example.

11 thoughts on “Displaying Shortcodes

  1. Sorry again to bother you with this. After you told me I found your forum comments concerning this issue.. (sometimes it’s just hard to explain to google what you want, google really has to work on that..)
    after a couple of tries, this is the code that worked for me

    [_code lang="php"]
    <?php
    $string = file_get_contents('../../wp-content/themes/matala/YF-Box.php');
    echo '[[php]' . htmlspecialchars($string) . '[/php]]';
    ?>
    [/_code]
    

    (without the

    _

    before

    code

    )

    Thanks for the great plugin and that hint, of course.

  2. Awesome, didn’t know this either so I used spaces like [ gallery ] to avoid displaying it when writing about it :) so to write what you wrote you used triple brackets? Like [[[gallery]]] to show [[gallery]] :D

  3. Pingback: WordPress: eckige Klammern bzw. Shortcodes in Code-Beispielen | WordPress & Webwork

Leave a Reply