Add Menu Item AFTER GeoDirectory Menu Items

This topic contains 13 replies, has 3 voices, and was last updated by  Paolo 9 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #28540

    Vi Wickam
    Expired Member
    Post count: 29

    Hi,

    I’m using wp_nav_menu_items to add a menu item to my primary menu. I’d like this to show after all of the GeoDirectory menu items.

    Getting the custom menu item to show is easy enough, but positioning it is proving elusive. Any help?

    FYI, here’s the call I’m using in my functions.php file.

    add_filter( ‘wp_nav_menu_items’, ‘add_login_logout_link’, 10, 2 );

    Also, is there a list of actions & filters supported by GeoDirectory?

    #28565

    Paolo
    Site Admin
    Post count: 31206

    Hi Mike,

    adding a very high number as priority (almost) always works in placing the new item as the last in the menu.

    Please try this:

    
    
    add_filter( 'wp_nav_menu_items', 'add_loginout_link', 9999, 2 );
    

    We only started writing the documentation about hooks and filters this week.
    http://docs.wpgeodirectory.com/category/dev/core-docs/hooks/

    We finally have an almost stable list and we hope to complete it by end of February. We have over 150 docs to write.

    For anything needed in the mean time, please don’t hesitate to ask.

    Thanks

    #28567

    Vi Wickam
    Expired Member
    Post count: 29

    >>adding a very high number as priority (almost) always works in placing the new item as the last in the menu

    That worked. Thanks. (I was on the right track, but didn’t try a high-enough priority.)

    A related question:

    How do I get GeoDirectory menu items to show in a widget area, instead of — or in addition to — the Primary Navigation Menu location?

    FYI, I’m using a Genesis theme (Minimum Pro, if it matters).

    Thanks!

    Mike

    #28576

    Paolo
    Site Admin
    Post count: 31206

    That is a bit more complex and requires Stiofan to have a look for you.
    The topic is flagged for him.
    Thanks

    #28640

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Mike,

    What menu items? You could alwasy add them as custom menu items?

    Stiofan

    #28645

    Paolo
    Site Admin
    Post count: 31206

    Given that our script only hooks to a menu lcation, we could be looking at a complex solution to solve a simple problem.

    You could use the shortcode [geodir_location_tab_switcher] for the location switcher in a text widget (add this in your theme’s functions.php to make text widgets shortcode ready:

    add_filter('widget_text', 'do_shortcode');

    ) and custom menu widget with custom links for the rest.

    Easier than adding functions.

    Let us know,

    Thx

    #28655

    Vi Wickam
    Expired Member
    Post count: 29

    >>What menu items? You could alwasy add them as custom menu items?

    Thanks. That will work.

    >>You could use the shortcode …

    Thanks. That will work, too.

    #28669

    Vi Wickam
    Expired Member
    Post count: 29

    >>You could use the shortcode …

    Well, that sort of works. The shortcode expands as expected, but it’s happening out of sequence.

    I’ve set the title for the text area to

    “Change Search Location”

    And added the shortcode. The shortcode expands, but is unexpectedly showing BEFORE the title.

    I tried adding a <div> </div> around the shortcode, but the shortcode is expanding before the <div>.

    I also tried moving the title into the text area, but got a similar result: shortcode expands first, then the hand-coded <h3> title.

    Any thoughts?

    Again, using Genesis here.

    #28679

    Vi Wickam
    Expired Member
    Post count: 29

    I may see the problem. The function referenced by the shortcode looks like produces output using echo. If true, this is problematic:

    From http://codex.wordpress.org/Function_Reference/add_shortcode

    Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results. This is similar to the way filter functions should behave, in that they should not produce expected side effects from the call, since you cannot control when and where they are called from.

    #28680

    Paolo
    Site Admin
    Post count: 31206

    Hi Mike,

    thanks for spotting this, I’ve asked Stiofan to look into it. I’m sure it’s an easy fix.

    Thanks

    #29267

    Vi Wickam
    Expired Member
    Post count: 29

    Hi, Paolo.

    Is there an update for this issue?

    Mike

    #29268

    Paolo
    Site Admin
    Post count: 31206

    Hi Mike,

    it’s in the queue for the next batch of releases. If everything goes well we should have it ready for tomorrow.

    Thanks

    #29537

    Vi Wickam
    Expired Member
    Post count: 29

    Looks like this weekend’s update resolved this issue.

    Thanks!

    #29542

    Paolo
    Site Admin
    Post count: 31206

    Yes, I was about to report here that we were able to fix the bug.
    🙂

Viewing 14 posts - 1 through 14 (of 14 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket