Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortcode Attribute Containing Bracket Issue

Tags:

wordpress

The Shortcode API states that you can't have square brackets in your attribute. Thus, the following would not work:

[tag attribute="[Some value]"]

In my case, the square bracket is required. What would be the best solution of getting around this problem? I've already tried escaping the content in my shortcode function, but had no luck.

I am using WordPress 3.3.1.

like image 556
Zachary Schuessler Avatar asked Nov 13 '22 11:11

Zachary Schuessler


1 Answers

Use some other special character in your shortcode and replace it square brackets in your shortcode function. - Since this is not what you want, here's an alternative.

This seems to be the only thing that I can think of that will work in your case, instead of relying on the Shortcode API, you can use "apply_filters" on the content, and then use preg_replace to write your own shortcode processing function.

like image 158
aghoshx Avatar answered Mar 03 '23 13:03

aghoshx