Add Menu Item AFTER GeoDirectory Menu Items
This topic contains 13 replies, has 3 voices, and was last updated by Paolo 10 years, 2 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: wp_nav_menu_items custom menu
-
AuthorPosts
-
January 22, 2015 at 9:49 pm #28540
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?
January 22, 2015 at 11:02 pm #28565Hi 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
January 22, 2015 at 11:35 pm #28567>>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
January 22, 2015 at 11:47 pm #28576That is a bit more complex and requires Stiofan to have a look for you.
The topic is flagged for him.
ThanksJanuary 23, 2015 at 4:33 pm #28640Hi Mike,
What menu items? You could alwasy add them as custom menu items?
Stiofan
January 23, 2015 at 5:04 pm #28645Given 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
January 23, 2015 at 6:16 pm #28655>>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.
January 23, 2015 at 7:29 pm #28669>>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.
January 23, 2015 at 9:34 pm #28679I 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.
January 23, 2015 at 9:42 pm #28680Hi Mike,
thanks for spotting this, I’ve asked Stiofan to look into it. I’m sure it’s an easy fix.
Thanks
January 30, 2015 at 7:47 pm #29267Hi, Paolo.
Is there an update for this issue?
Mike
January 30, 2015 at 8:01 pm #29268Hi Mike,
it’s in the queue for the next batch of releases. If everything goes well we should have it ready for tomorrow.
Thanks
February 2, 2015 at 6:14 pm #29537Looks like this weekend’s update resolved this issue.
Thanks!
February 2, 2015 at 6:27 pm #29542Yes, I was about to report here that we were able to fix the bug.
🙂 -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket