Disable top level menu link

resolved (29 posts) (8 voices)

  1. mytzlplik
    Member

    Is it possible to disable the page link to a top level menu item?
    ie. I have sub pages under a main navigation heading. I don't want the main navigation button to be clickable since it's a bit pointless repeating the content of my subpages on the top level page?

    Posted 3 years ago #
  2. Uniq
    Support

    Hi mytzlplik,

    To do so, go to Awake theme seetings -> Navigation.
    In the list, Check the top level menu item you would like to exclude and save the changes.

    An other way to do this, would be to use WordPress' Menus.

    Uniq

    Posted 3 years ago #
  3. mytzlplik
    Member

    Nah, it's alright I figured it out.
    I didn't want to exclude an item from the menu, but rather just disable the top level item's hyperlink.
    i.e. If I had in my main navigation, called 'About Us', then sub pages in the drop down menu of say 'Who we are', 'What we do' etc I didn't want the 'About Us' to link back to a page.

    I fixed it by adding a custom link into the menu from Wordpress's menu management, then adding my sub-pages below that. In the top level link, you cannot add one without a link entered, so just put # in the box and all done!

    Works a treat.

    Posted 3 years ago #
  4. Uniq
    Support

    Glad you fixed it, mytzlplik!

    Posted 3 years ago #
  5. mytzlplik
    Member

    hmm which brings me back to my old problem of top level menu items not showing the 'active' state when I'm on a sub-page. :(

    Now when I select one of the sub=pages in the drop down menu and the page loads, the 'About Us' tab in the main navigation is no longer staying 'active' (with the darker overlay)?

    This is why the Home button doesn't show as active either when on the homepage. Because it's not set up to link to a page but rather a custom link (being my site URL).

    Any way to restore the active state?

    Posted 3 years ago #
  6. mytzlplik
    Member

    bump

    Posted 3 years ago #
  7. Elliott
    Support

    Hello mytzlplik,

    We can try this, not sure if it will work for you though.

    Open up /wp-content/themes/awake/lib/scripts/custom.js and add the following code at the beginning..

    jQuery(document).ready(function(){
    jQuery('#main_navigation ul li a:not(#main_navigation ul li ul li a)').attr('href', '#');
    });

    Make sure that in your wordpress 3.0 menu that you have no custom links defined.. only pages.

    Let us know if this works for you mytzlplik.

    Posted 3 years ago #
  8. mytzlplik
    Member

    Brilliant.. Thanks Elliott.
    Works great.

    I've added a Home button to my custom navigation menu, using a custom link (as the front page doesn't require a 'page' to be set up with the theme.

    I'm guessing this is why the Home button's active state does not stick when I'm on the home page?.. Can I create a page for the homepage without affecting anything else, just so my custom menu uses a 'page' rather than a 'custom link' linking back to my base URL?

    Posted 3 years ago #
  9. mytzlplik
    Member

    hmm actually.. I spoke too soon.

    That disables all top level menu items regardless of whether they have sub-pages associated with them.. hmmm

    Posted 3 years ago #
  10. Elliott
    Support

    Hey mytzlplik,

    It is probably best if you do this on a per item basis so you have complete control..

    jQuery(document).ready(function(){
    jQuery('#menu-item-35 a').attr('href', '#');
    });

    This will disable the top level menu item of page ID 35. Just keep adding a line and changing the page ID of the ones you want to disable like this..

    jQuery(document).ready(function(){
    jQuery('#menu-item-35 a').attr('href', '#');
    jQuery('#menu-item-4 a').attr('href', '#');
    jQuery('#menu-item-22 a').attr('href', '#');
    });

    You can view the page ID's by right clicking -> View Source and they should be located within the header as <li id = 'menu-item-35'>.

    Let us know if this helps mytzlplik.

    Posted 3 years ago #
  11. mytzlplik
    Member

    OK, I think I've really got it this time..
    Combining your earlier advice Elliott, with your latest advice, I came up with the following;

    This disables the top level link and replaces it with '#', but leaves the sub-menu links alone if they exist.

    jQuery(document).ready(function(){
    jQuery('#menu-item-674 a:not(#main_navigation ul li ul li a)').attr('href', '#');
    jQuery('#menu-item-675 a:not(#main_navigation ul li ul li a)').attr('href', '#');
    });

    Consider this one solved.. Thanks for all your assistance.
    Might be one to add to the tutorials.

    Posted 3 years ago #
  12. Elliott
    Support

    Glad you got it fixed mytzlplik, added to tutorials and marked as solved. If you need anything else then let us know.

    Posted 3 years ago #
  13. mytzplik and Elliott, I've tried BOTH fixes in my custom.js file but the top level menu links do not de-activate. Can anyone see what I am doing wrong? I am de-activating everything BUT Home and Contact, and I think my page IDs are correct. Below is my code at the beginning of custom.js. Thanks in advance.

    http://gosselinconsultinggroup.com/test/

    jQuery(document).ready(function(){
    jQuery('#menu-item-88 a').attr('href', '#');
    jQuery('#menu-item-108 a').attr('href', '#');
    jQuery('#menu-item-110 a').attr('href', '#');
    jQuery('#menu-item-112 a').attr('href', '#');
    });

    Posted 3 years ago #
  14. Uniq
    Support

    Hi RamsellStudio10,

    jQuery(document).ready(function(){
    jQuery('#menu-item-88 a').attr('href', '#');
    jQuery('#menu-item-108 a').attr('href', '#');
    jQuery('#menu-item-110 a').attr('href', '#');
    jQuery('#menu-item-112 a').attr('href', '#');
    });

    Instead of #menu you will have to use .page so the code becomes:

    jQuery(document).ready(function(){
    jQuery('.page-item-88 a').attr('href', '#');
    jQuery('.page-item-108 a').attr('href', '#');
    jQuery('.page-item-110 a').attr('href', '#');
    jQuery('.page-item-112 a').attr('href', '#');
    });

    Let me know if this did the trick!

    Cheers,
    Uniq

    Posted 3 years ago #
  15. Thanks Uniq, worked perfectly. I appreciate it.
    Rich

    Posted 3 years ago #
  16. I spoke too soon, that fix deactivates all the subpages as well. How do I keep the subpages? Thanks.

    Posted 3 years ago #
  17. Elliott
    Support

    Hehe, that was the same response myztlplik gave when he tried it.

    Try this..

    jQuery('.page-item-2 a:first').attr('href', '#');

    Just throw a :first in there and it should only take care of the top level link. Let us know if it works for you RamsellStudio10.

    Posted 3 years ago #
  18. Yes, a couple of cache dumps later and it worked. Consider this solved, thanks!

    Posted 3 years ago #
  19. Elliott
    Support

    Glad it works for you RamsellStudio10, if you need anything else then let us know.

    Posted 3 years ago #
  20. flashden422
    Member

    Thank you for this info. Using the following line of code in the custom.js file worked perfect:

    jQuery(document).ready(function(){
    jQuery('.page-item-30 a:first').attr('href', '#');
    });

    Another way to find out the page number is by going to the Awake Settings > Navigation and then checking the box next to the menu item you want to find the number for ( temporarily ). When you check the box the number will display below in the "Selected pages will will not show up in the menu" box.

    Thanks again for the help on this forum.

    Posted 3 years ago #
  21. Elliott
    Support

    Thanks for the tip flashden422, glad you got it working. Looking over these posts I realized that you can get the same effect by using WP 3.0 menus in case anyone else wants to do this in the future.

    Posted 3 years ago #
  22. ssheehanbernard
    Member

    Is there a post that elaborates on this: I realized that you can get the same effect by using WP 3.0 menus in case anyone else wants to do this in the future ?

    I'm trying to disable the top-level link as well but wondering if there's an easier way with 3.0. Thanks!

    Posted 3 years ago #
  23. Elliott
    Support

    Hello ssheehanbernard,

    When you edit your menu create a "Custom Link". (see attached image) And for the URL field place a # character.

    Attachments

    1. 1.jpg (6.4 KB, 0 downloads) 3 years old
    Posted 3 years ago #
  24. I believe my question is related to this topic as well.

    http://yourstoryisyoursuccess.com.s101257.gridserver.com/

    I want to disable all the top menu items (but one i.e. Home) and make sure all the sub pages are active.

    I have followed most of the instructions on this page to accomplish what I need to do. All the top links have been now replaced with # .

    However I need to make the home button active. Can you please guide me in the right direction on how to do that?

    Thanks

    Nabeel

    Posted 3 years ago #
  25. Elliott
    Support

    Hello nabeelahmed,

    If you are using the WP 3.0 menus and if your Home link is a custom menu then you would just need to place your domain name in the URL field.

    "http://yourstoryisyoursuccess.com"

    Is that what you were wanting?

    Posted 3 years ago #
  26. I am not sure what do you mean by WP 3.0 menus as I havent made any changes other than what was suggested on this forum to another user. I believe the code was:

    jQuery(document).ready(function(){
    jQuery('#main_navigation ul li a:not(#main_navigation ul li ul li a)').attr('href', '#');
    });

    By using this code I was able to disable all the top links but realize that the home link still needs to be functional.

    Posted 3 years ago #
  27. Elliott
    Support

    You can enable WP 3.0 menus for inFocus by following the solution in this thread, (Awake is enabled by default)

    http://mysitemyway.com/support/topic/wordpress-v3-menus

    I recommend going this option. If you still want to do it that way then go ahead and send us a link to your page so we can find the ID / CSS class of your home link.

    Posted 3 years ago #
  28. Thank you for your help. You guys are the best.

    Posted 3 years ago #
  29. snapkrakelpop
    Member

    helped me a great deal! thanks for this post :)

    Posted 2 years ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme