Why is colon : striped out of url when shortcode used in nav menu?

Any thoughts / solutions on this problem? I’ve created a wordpress shortcode that returns a url (eg. https;//…). It works just fine when placed in content in a post. But if I use the shortcode in a nav menu item it returns the url but the colon : is striped out (e.g. https//… I can’t figure out why the : is striped. Here’s the code:

function photoStorePath() {
global $siteURL;
return esc_url( $siteURL);
//returns https://... if in content, but https// if in menu
add_shortcode( "psPath", 'photoStorePath');

are you certain $siteURL contains a colon before you run this fucntion? (have you echoed it out to test?)
In other words: Are you sure it’s esc_url that’s doing it to your string?

Yes, I’ve triple checked that is contains a colon. I’ve done that by debugging and looking at the var $siteURL and I have also placed the shortcode [psPath] in a post. When in a post the shortcode properly expands with https:// but if I use the shortcode in a WP menu item it expands sans the colon - https//

It’s been a while, but IIRC, post text and menu text are treated differently. If the short code for posts works make sure you save that! Have you looked in the Codex for menu hooks?

Yeah, the shortcode seems to be correct, and as I mentioned, it works if placed in content, but in a menu item it just strips out the colon (everything else is good.) I’m beginning to think this is a WP bug… Here’s how I’m using it in a WP Menu:


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.