-
AuthorPosts
-
July 18, 2014 at 10:41 pm #293164
Hi,
Is it possible to add the parent page as a title/link to the nested sub-page menu on the sidebar?
Thanks!July 19, 2014 at 2:43 am #293203Hey dubyajay!
Not with the automatic built in menu but you could use a plugin or the regular WordPress menu widget to add your own custom menu to a page.
Best regards,
DevinJuly 19, 2014 at 5:07 pm #293393Thanks for your reply. I found this topic in the forum: https://kriesi.at/support/topic/nested-sub-page-navigation/#post-119777 .
Was it not added to the theme?
Thanks!July 20, 2014 at 9:28 am #293571Hi!
Yes, I added a filter to the sidebar menu. To show the parent page insert this code into the child theme functions.php file or enfold/functions.php:
add_filter('avia_sidebar_menu_display_child', '__return_false', 10, 3);
Cheers!
PeterJuly 20, 2014 at 5:22 pm #293623Thank you for your reply! I have added the code to functions.php in the child theme (which is the active theme :-) ). I cleared the browser cache but am not seeing the parent page as a title/link above the list of sub-pages. I am using the latest version of enfold.
Is there something else I need to add?
Thanks!July 21, 2014 at 4:52 pm #293912Hi!
No, the code should work without any additional changes. Please create us an admin account and post a link to your website and I’ll check why the code doesn’t work.
Cheers!
PeterJuly 31, 2014 at 5:13 pm #298318This reply has been marked as private.July 31, 2014 at 5:26 pm #298331This reply has been marked as private.August 1, 2014 at 6:25 pm #298879Hi!
Please create us a ftp account. I need to edit the theme files to debug the code.
Regards,
PeterAugust 1, 2014 at 7:08 pm #298890This reply has been marked as private.August 1, 2014 at 7:15 pm #298896This reply has been marked as private.August 2, 2014 at 8:50 am #299091Hi!
Eventually I noticed the wp_list_pages function doesn’t include the parent page at all. Fortunately Enfold comes with some useful filters which help us to add the parent page with some additional code – I added it to the child theme functions.php file:
add_filter('avf_sidebar_menu_filter', 'avia_add_parent_page_to_sidebar', 10, 3); function avia_add_parent_page_to_sidebar($sidebar_menu, $args, $post) { $parent = $post->ID; if(!empty($post->post_parent)) { if(isset($post->ancestors)) $ancestors = $post->ancestors; if(!isset($ancestors)) $ancestors = get_post_ancestors($post->ID); $root = count($ancestors)-1; $parent = $ancestors[$root]; } $current = ($post->ID == $parent) ? "current_page_item" : ""; $parent_page = '<li class="page_item page-item-'.$parent.' ancestor_page_item '.$current.'">'; $parent_page .= '<a href="'.get_permalink($parent).'">'.get_the_title($parent).'</a>'; $parent_page .= '</li>'; $sidebar_menu = str_replace("<ul class='nested_nav'>", "<ul class='nested_nav'>{$parent_page}", $sidebar_menu); return $sidebar_menu; }
Cheers!
PeterAugust 2, 2014 at 3:32 pm #299150You. Are. Awesome. Thank you so much for taking the time to make the change.
Enfold is becoming a fave.August 2, 2014 at 3:50 pm #299153Hey!
Glad I could help you :)
Best regards,
Peter -
AuthorPosts
- The topic ‘Nested sub-page menu on sidebar’ is closed to new replies.