Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress- do not execute shortcodes inside code tags

Tags:

php

wordpress

I just noticed when I was trying to print on the page how to execute a certain shortcode, that the shortcode is executed even within the < code > tags.

I am trying to get it to where I can display EVERYTHING inside the code tags and not have wordpress do anything to it, ie:

<code>[shortcode]</code>

Exactly as you see the above line here on stackoverflow, I want it to display on my wordpress blog, even if [shortcode] is a shortcode (do not execute shortcodes).

I tried using strip_shortcodes() http://codex.wordpress.org/Function_Reference/strip_shortcodes

However, this actually takes the entire text out of the content, not just prevents it from being executed.

Any idea how to do this?

like image 436
MultiDev Avatar asked Oct 15 '25 16:10

MultiDev


2 Answers

I just found the answer and I thought instead of deleting my question I would answer it myself. I have been working with Wordpress for years and have never heard of this issue.

To get wordpress to display shortcodes and not execute them, you must use double brackets, ie:

[[shortcode]]

Wordpress will display it in single brackets, unexecuted.

like image 189
MultiDev Avatar answered Oct 18 '25 12:10

MultiDev


If you're having shortcodes with content try this

[[shortcode]this is the content[/shortcode]]
like image 39
Xaver Avatar answered Oct 18 '25 10:10

Xaver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!