Viewing 15 replies - 16 through 30 (of 30 total)
  • Nevermind…I got it. By full html output, you meant that in the most literal terms possible. So I did the full html a href output and it works!!! Thank you… Huge time saver!

    If you need a quick graphic done, like an icon, you’ve got one on me. ?? spiderflystudios.com

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    @kahil

    Good to know that your problem is resolved, but I’m still not quite sure why [authorinfo field='user_url' nospan='true'] is working on some navmenus and not on others. Will be trying to find the exact cause on weekend.

    About the icon, why not ??

    Dear Gagan,

    wonderful work! Thank you so much for sharing.

    I have written a small example for those who are a little lost when it comes to coding up the functionality of your very useful plugin…

    Problem example
    we often work on our localhost server when developing a new site. This means that our initial domain is folder based, so we access it using https://localhost/new-project. However when we deploy live we have our client domain, so the site is accessed with something like https://new-project.com/. Now if we want to access a custom post-type (eg: products) archive page from the main menu, we have the following links:

    Localhost: https://localhost/new-project/products
    Live server: https://new-project.com/products

    So may times we have forgotten to change the custom link in the menu, which breaks the live site, because it points to https://new-project.com/new-project/products which of course does not exists.

    The Solution: ‘Shortcodes in Menu’ to the rescue.

    First we create the shortcode logic in our functions.php file:

    function sy_get_domain_name(){
    	$domain_name =  preg_replace('/^www\./','',$_SERVER['SERVER_NAME']);
    	return $domain_name;
    }
    function isLocalhost(){
    	if("localhost" == sy_get_domain_name()) return true;
    	else return false;
    }
    //menu short code test
    // [syMenuLink]
    add_shortcode( 'syMenuLink', 'menu_shortcode' );
    function menu_shortcode( $atts ) {
    	$url = 'https://'.sy_get_domain_name();
    	switch (true){
    		case isLocalhost():
    			$url = $url.'/only/listing';
    			break;
    		default:
    			$url = $url.'/listing';
    			break;
    	}
    	return $url;
    }

    we have 3 functions:

    • sy_get_domain_name() – returns our current domain name without the protocol, eg localhost
    • isLocalhost() – make use of the above function to test if this is the localhost
    • add_shortcode( 'syMenuLink', 'menu_shortcode' ) – registers the shortcode [syMenuLink]
    • menu_shortcode( $atts ) – defines the logic of our menu short code

    Then in our menu section of the Dashboard, we include a new custom menu Link. In the URL field we enter our new shortcode [syMenuLink] created above.

    You should now see your menu link being correctly constructed, regardless of the site being visited.

    Hope this helps someone out there.

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    Aurovrata,

    Thanks ??

    I’ll include a link to your reply in the description itself so that its easier to find and users can get better description.

    Also, my friend is helping me out with coding a completely different section for shortcodes instead of using the “Custom Link” in the menus. Its almost ready to be shipped. Here’s the development thats going on currently : Shortcode in Menus

    Wonderful to read you Gagan. Happy to test your new section once it’s read to fly. Keep me posted ??

    PS: We’re based in Chennai, are you also in India?

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    @aurovrata,

    Just uploaded the new version with the ShortCode section in the Menus, though you might need to enable that section from the screen options(as explained in the screenshots).

    About me, yes I’m also from India, currently living in Pune, working as a freelancer for some offshore clients.

    I just saw your new update with the Shortcode box, nice idea!

    So does it mean we insert the shortcode in the title section of the box?

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    @aurovrata

    Thanks for the compliment, I was trying to do that when I started that plugin, but since nav menus are not that much extendible in WordPress, it was taking a lot of time and hit and trial. So my friend Saurabh implemented that feature in the plugin in the last release.

    About adding the shortcode, the earlier method still works fine, but you can use the shortcode box as well, writing the shortcode not in the title section, but in the textbox below the title. I should make it more clear, adding label to it just now ??

    Cool Gagan, thanks for the details.

    So is the Title section used for anything?

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    @aurovrata

    Its just used to display the title in the nav-menus in the dashboard so that one shortcode menu item can be distinguished from another shortcode menu item.

    Another quick question Gagan, is it possible to add shortcodes to the custom Link title ?

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    @aurovrata

    I’ll be trying to in corporate that functionality this coming weekend. If everything works out fine, will release that on Monday.

    Works great. I’ll enjoy playing with this.

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    @fredvdp

    Good to know it worked out for you ??

Viewing 15 replies - 16 through 30 (of 30 total)
  • The topic ‘How does it work?’ is closed to new replies.