I have a theme and I want to show vistors how shortcode format is in <pre>
tag. But when I add shortcode in <pre>
, it shows what shortcode does. I just want to show shortcode format in plain text. How to do that?
2 comments
Comments are closed.
A) If you want to show the shortcode syntax you can try to write it with double brackets in the editor:
It will then display as
on your frontend and it will not activate the shortcode callback.
B) Or if you want some extra formatting, you could define your own pretty format via shortcode:
You would then write for example this in your editor:
and the output would be:
A more crazy but reliable workaround. You can paste the invisible space char
­
after the first bracket. I use that approach to workaround a lot of rendering problems when presenting code. In javascipt the syntax model is:The tricky part is to grab the character in unicode format and paste in PHP protocol. Otherwise the
­
will be rendered or converted into a-
hyphen. The char is invisible for the cursor, so you cant select it alone. However, just produce it once with javascript and copy the[g
part and paste/ replace in the editor.You can use the same trick to always use element without captions, in wordpress, by pasting a invisible space as caption on single images.
Here is the shortcode with the space. Paste in your wordpress editor and back-delete each char. After the
g
the cursor stops, before contiune with deleteing the bracket…Note, if you see
-
instead, your encoding is wrong or the information got broken in the copy by your device.