How can I prevent a main menu item with sub items from being clickable in Wordpress?

人盡茶涼 提交于 2019-12-09 23:43:45

问题


Here is my site: http://wake9.com/blogs/norcal-merced-wakesurfing-competition-2009/.

Notice the menu item "Photos and Results". Hover over it and you will see sub menu items. I want to be able to click on the sub-menu items but the main menu item shouldn't be a page or be clickable. The only way i could get this item on the menu was to make it a page. Is there a way to just have a menu item that has sub menu items to content, but the actual menu item isn't clickable? I was thinking about using JQuery to remove the anchor tag, but that is a real hack and I want to know if there is an easier way.

Thanks in advance!


回答1:


One option would be to use Page Links to plugin and set the main link as '#' . I tried this and it works in my blog.




回答2:


What about using the jQuery.remove to remove the element?

something like this:

function removeLinkAttrib() {
  var attrib =  jQuery(#menus).find("a").attr("Photos and Results");
  jQuery(attrib).remove;
}

I'm not sure if $(attrib).remove; will work, but you get the picture :)




回答3:


(this answer is for people using Wordpress.com free sites):

You can go to Appearance > Menus, then add a custom link to the menu by clicking 'Links' in the left-hand column, and adding "#" as the URL (and whatever you want as a label). Then add this link to the menu. Open the options for the new menu item in 'Menu Structure', and then delete '#' from the URL, so the field is blank, and save changes. Now you can add sub-menus to this menu item, and there will be no link for this item on the main menu...works for me.



来源:https://stackoverflow.com/questions/887464/how-can-i-prevent-a-main-menu-item-with-sub-items-from-being-clickable-in-wordpr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!