I'm trying to set shortcode attribute value to ' " (single and double quote) by using escaped values ' ".

Example: [shortcode attr="' ""]test[/shortcode]

As soon as I switch to visual editor, they get converted back to ' " and shortcode is now broken. How does one properly escape shortcode attributes so that they can work even after switching between visual and text editor?

  • FWIW, I wonder if you should take one step further back and try to find a way around requiring attributes of this type at all.
    – mrwweb
    Apr 5, 2016 at 22:44
  • A client added double quote in my shortcode and everything broke because WordPress unescaped the entered attribute value. I'm not requiring anything, I just need a way to safely escape all values. Apr 7, 2016 at 9:45

1 Answer 1


I suggest using keywords for them. so you would do something like [shortcode attr="single_quote double_quote"]test[/shortcode]. Then, while parsing the shortcode you can change them back.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.