-
AuthorPosts
-
May 22, 2020 at 11:20 pm #1215338
I would like to be able to hide specific pages (and/or subpages) in Enfold’s auto-generated sidebar menu — is this possible? Our site is pretty large so having to create separate custom navigation menus would be really time-consuming. Example: This screenshot is showing my sidebar menu where the current page is showing it’s subpage(s). I would like to hide this subpage so that it can’t be seen/accessed from the menu. Any help/ideas would be appreciated! Thank you.
May 25, 2020 at 11:02 pm #1216311Hey Ashley,
Sorry for the late reply, here is a script that toggles the sub-menu items and the sub-menu can be expanded on the current page.
Try adding this code to the end of your functions.php file in Appearance > Editor:function custom_script(){ ?> <script> (function($){ $(document).ready(function(){ $('#menu-supermarket-shop-1 > li.menu-item-has-children').find('ul').hide(); $('#menu-supermarket-shop-1 > li.menu-item-has-children').click(function () { $('#menu-supermarket-shop-1 > li.menu-item-has-children').not(this).find('ul').hide(); $(this).find('ul').toggle(); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_script');Please adjust the
#menu-supermarket-shop-1to your sidebar navigation ID, if you need help adjusting this to your site please include a link to an example page.
Also, the script above works best if the parent menu item has no link so that clicking it will expand the menu instead of going to a page.Best regards,
MikeMay 27, 2020 at 4:18 pm #1217009Hey Mike, thank you so much for your help! I used the snippet that you posted and actually tweaked it a little to fit my situation better. Since I wanted to hide the subpages of one specific page of the Page Sidebar navigation (not my main navigation menu), I used:
function custom_script(){ ?> <script> (function($){ $(document).ready(function(){ $('.nested_nav > li.page-item-31276').find('ul').hide(); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_script');Thank you again!
May 27, 2020 at 6:17 pm #1217094Hi ashleylyn07,
Glad you got it working for you! :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.
