How to Prevent Shortcode from Working?


#1

Hello Friends. I wish you have a nice day. :smile:

Today, I have created my own shortcode plugin Google+ Badge Shortcode for Blogger but now, I have a problem. When I was going to give example code of shortcode, I was unable to give it because it got changed into Google+ Badge. So I putted images in which I have written example.

My question is, how can I prevent a line of shortcode to get changed?

Thanks.


#2

how about using html escape tool.

(ignore this text, just so i can post lol)


#3

But according to HTML, ‘[’ or ‘]’ is not a character of HTML that’s why @Mohammad used it in Shortcodes plugin. :frowning:


#4

okay i just got it lol. wrap your shortcode.js in a conditional tag for url. eg:

<b:if cond='data:blog.url != "http://your_url_to_prevent_script_from_running"'><script src='http://yourscriptdomain/shortcodes.js type='text/javascript'/></b:if>

#5

See, like I have installed Facebook Page Plugin shortcode on my blog, how to prevent [facebook src=‘bloggertricks’/] from getting changed into facebook page plugin?


#6

yep like i said, just specify which page or URL the script will not run. i’ve already gave an example. you’ll not know until you tried it.


#7

Yeah! I got it. Thanks :smiley:

~Shivansh


#8

But @Chelyz_Marx, what if I want to stop it from displaying in some more pages? Because I am thinking to create some more shortcodes. So how?


#9

The simplest solution is to keep the shortcode variable you use inside your template different from what you share with your readers on your tutorial. For example for the image shortcode that we published on MBT. We are using [img] shortcode variable inside the mbt template but for readers we created a different script with variable [image]

This is the only way to share shortcodes in their original syntax with your readers.


#10

Thanks Mohammad. Now, I can share it without any hassle.


#11