Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #293164

    Hi,
    Is it possible to add the parent page as a title/link to the nested sub-page menu on the sidebar?
    Thanks!

    #293203

    Hey 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,
    Devin

    #293393

    Thanks 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!

    #293571

    Hi!

    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!
    Peter

    #293623

    Thank 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!

    #293912

    Hi!

    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!
    Peter

    #298318
    This reply has been marked as private.
    #298331
    This reply has been marked as private.
    #298879

    Hi!

    Please create us a ftp account. I need to edit the theme files to debug the code.

    Regards,
    Peter

    #298890
    This reply has been marked as private.
    #298896
    This reply has been marked as private.
    #299091

    Hi!

    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!
    Peter

    #299150

    You. Are. Awesome. Thank you so much for taking the time to make the change.
    Enfold is becoming a fave.

    #299153

    Hey!

    Glad I could help you :)

    Best regards,
    Peter

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Nested sub-page menu on sidebar’ is closed to new replies.