General Question

manuel_alarcon's avatar

How to disable links on top menu elements on WP's MenuManager?

Asked by manuel_alarcon (294points) August 11th, 2011

Hi, Im modifying a WP site, where its navigation menu is running on MenuManager. I want to disable the links on the top elements of this menu and I cant find enough documentation about it…

Observing members: 0 Composing members: 0

4 Answers

funkdaddy's avatar

Is it this plugin? > Menu Manager

If so, I’d say use the “custom” option to set up your top level elements and don’t enter anything for the URL.

If that doesn’t leave the link portion out of those, then you’ll need to modify the plugin or add some javascript to disable those links.

Is that something you’d be comfortable doing? Happy to give more direction but not sure if we’re on the right track yet.

manuel_alarcon's avatar

yes, that is the plugin @funkdaddy thanks… I didnt developed the site, im just fixing the gaps left by the developer. So I dont really know if making the whole menu again is easier than get into the code; i can work my way in wordpress code but plugins are black boxes to me yet

funkdaddy's avatar

If we want to leave it as a “black box” that just doesn’t it’s thing and we don’t mess with it, we can use javascript to disable those menu items.

It looks like you can give your menu items a class in the admin. Give all the ones you don’t want to link directly a class like “no_link” or whatever you want to call it (I’ll use this as an example). This way if you want to disable links anywhere in the menus, you can.

It also looks like it loads jQuery already for parts of the menu, so we’ll just piggyback on that. You can add this to the footer file of your theme (or the header file, either will work)

<script type=“text/javascript”>
$(document).ready(function() {
$(‘li.page_item a.no_link’).click(function(e) {

Where I have “no_link” use whatever class name you want to use throughout. That should disable whatever links you want to from clicking with the mouse but should leave them working when someone hovers over.

Technically they can probably still tab through with the keyboard and use those links as well, probably not a bad thing.

I haven’t tested this anywhere, so if there’s a problem with it, I apologize. Would it be possible to check out a link to the site?

The other way to go about it would be to modify the plugin slightly. The problem would be if the developer makes updates later and someone updated through the WordPress admin they would probably be overwritten.

manuel_alarcon's avatar

I’ve fixed it! but,... Im ashamed… turns out that checking the site I realized the plugin assigns the complete link as a string, so if you write “hey” into it, the link will appear as “hey”,... so I just replaced the main items with a custom one with a link like ”#”... works like a charm. I was being lazy asking, but that function is very helpful, thanks, I’ll keep it in mind

Answer this question




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther