Simple example of a shortcode:
function s_print( $atts ){
return 'http://abc.com/?foo=1&bar=2';
}
add_shortcode( 'my_shortcode', 's_print' );
And it returns:
http://abc.com/?foo=1&bar=2
This function inserts a link to page’s body via shortcode [my_shortcode], but & is always changed to &, and this breaks the link (it’s not working anymore).
I googled a lot. There are some solutions:
wp_specialchars_decode($foo);
remove_filter('the_content','wptexturize');
But those seems to be only for use in theme (functions.php) and it doesn’t work for a shortcode (I tried adding it before or inside the shortcode function).
I don’t want to fall to last solution, which is commenting some lines in WordPress formatting.php file because I’m working on a plugin which will be used by many people.
I had a similar problem that I addressed with the
clean_urlfilter. See the edit on my answer here.It wasn’t in a shortcode, so I can’t guarantee it’ll work in your particular situation. Might be worth a shot though.
EDIT by oyatek
(modified solution from the link aboove):