WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Smarter Navigation] smarter-navigation for dynamic menu highlighting

[Plugin: Smarter Navigation] smarter-navigation for dynamic menu highlighting

  • Hi Scribu,

    This is a really handy plugin. The nex/previous post links work just as I need them to. My question is this: can I use any functions from this plugin to return a string with the name of the referrer (not a link)? So, something like the referrer_link() function already written in, but somehow modify it to return just a string?

    The idea is this: I would like to use this string within a conditional tag, to test the referrer for a given post. I’d like to be able to use this to get the dymanic menu highlighting to work. Something along the lines of

    if(referrer())='x'
    {echo " class=\"current_page_item\""; }

    a possible snippet from my menu:

    <li
    <?php if(is_category('Paintings' {
    echo " class=\"current_page_item\""; } ?>
    <?php elseif(referrer())='Paintings' {
    echo " class=\"current_page_item\""; } ?>>
    <a href="/category/paintings"><span>Paintings</span></a>
    </li>

    My problem is that I have posts which belong to multiple categories. If the user links to a single post from a specific category page, I would like the menu tab for that category to stay highlighted (even though the single post may also belong to other categories). So basically, I just need to test the referrer if possible.

    Thanks for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • If you download the development version (1.2b), you can try using get_referrer_url()

    In version 1.2, you can use get_referrer_category():

    function is_category_or_referrer($name) {
        return is_category($name) || $name == get_referrer_category()->name;
    }
    
    <li
    <?php if ( is_category_or_referrer('Paintings') ) {
        echo " class='current_page_item'";
    } ?>
    >
    ...

    Thank you thank you! Just updated the plugin and it was exactly what I needed! Great plugin, I’ll be using it on many more sites in the future.

    Scribu,
    can you please tell me how to use the get referrer category?
    I’m using smart nav onmy website and it’s not working:
    http://www.twitterevolutions.com/
    maybe this will help?

    thanks!

    Before get_referrer_category(), did you replace previous_post_link() with previous_post_smart() in your theme?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Smarter Navigation] smarter-navigation for dynamic menu highlighting’ is closed to new replies.
Skip to toolbar