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

    Do you have any code handy for adding the parent page (preferably linked) to the sidebar navigation. I like using the automated sidebar navigation, but it’d be nice if the parent page showed above the sub-menu list. For example, if I could have “About The FPR” show up at the top of the right sidebar on http://fpronline.org/about-the-fpr/strategy/ (preferably linked to http://fpronline.org/about-the-fpr/) , that would be nice :) Do you have a snippet for that handy?

    Thanks!

    #380936

    Hi sky19er!

    Please add following code to Quick CSS in Enfold theme options under General Styling tab

    .page-id-36 ul.nested_nav:before {
    content: 'About The FPR';
    color: black;
    font-size: 18px;
    }

    Best regards,
    Yigit

    #381065

    Thanks, but that’s “semi-manual” ;) Then I’d have to add that for every page in the section and update it every time a page is added in the section, etc. Plus it doesn’t have the linking feature. I was hoping for something more automated, maybe via php / a child theme file? Thanks again.

    #381385

    Hi!

    You can edit functions-enfold.php. Find this code on line 991:

    $default_sidebar = false;
                    $sidebar_menu .= "<nav class='widget widget_nav_menu $display_child_pages'><ul class='nested_nav'>";
                    $sidebar_menu .= $children;
                    $sidebar_menu .= "</ul></nav>";

    Replace it with:

    $default_sidebar = false;
    				$parent = get_the_title($post->post_parent);
    				$parentlink = get_the_permalink($post->post_parent);
                    $sidebar_menu .= "<nav class='widget widget_nav_menu $display_child_pages'><ul class='nested_nav'>";
    				$sidebar_menu .= "<a href='{$parentlink}'>$parent</a>";
                    $sidebar_menu .= $children;
                    $sidebar_menu .= "</ul></nav>";

    Regards,
    Ismael

    #382867

    Thanks, Ismael — that looks like what I’m talkin’ ’bout! ;) And could you remind me how to handle that via a child theme? I have the child theme all set up and activated, but do i use functions-enfold.php in the child theme, or just functions.php? And what exactly would I include in the child theme file? I got it working by editing the functions-enfold file directly, but can’t seem to get it to work via the child theme. Thanks again!

    #383215

    Hi!

    functions-enfold.php file is not recognized in child theme, so you should add modified function into functions.php file of your child theme

    Regards,
    Yigit

    #383375

    Hmm, I’m still having issues — can’t seem to get the code right without causing an error — any chance you could tell me exactly what I’m supposed to put in the functions.php file of your child theme? Sorry to bug.

    #384272

    Hey!

    You can copy the whole avia_sidebar_menu on the child theme’s functions.php:

    function avia_sidebar_menu($echo = true)
        {
            $sidebar_menu = "";
    
            $subNav = avia_get_option('page_nesting_nav');
      
            
            $the_id = @get_the_ID();
            $args 	= array();
    		global $post;
    
            if($subNav && $subNav != 'disabled' && !empty($the_id) && is_page())
            {
                $subNav = false;
                $parent = $post->ID;
                $sidebar_menu = "";
    
                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];
                }
    
                $args = array('title_li'=>'', 'child_of'=>$parent, 'echo'=>0, 'sort_column'=>'menu_order, post_title');
    
                //enables user to change query args
                $args = apply_filters('avia_sidebar_menu_args', $args, $post);
    
                //hide or show child pages in menu - if the class is set to 'widget_nav_hide_child' the child pages will be hidden
                $display_child_pages = apply_filters('avia_sidebar_menu_display_child', 'widget_nav_hide_child', $args, $post);
    
                $children = wp_list_pages($args);
    
                if ($children)
                {
                    $default_sidebar = false;
                    $sidebar_menu .= "<nav class='widget widget_nav_menu $display_child_pages'><ul class='nested_nav'>";
                    $sidebar_menu .= $children;
                    $sidebar_menu .= "</ul></nav>";
                }
            }
    
            $sidebar_menu = apply_filters('avf_sidebar_menu_filter', $sidebar_menu, $args, $post);
    
            if($echo == true) { echo $sidebar_menu; } else { return $sidebar_menu; }
        }
    

    Do the modification above.

    Cheers!
    Ismael

    #384657

    Ahh, I had the `if(!function_exists(‘avia_sidebar_menu’))
    {` in there, which seemed to break it — thank you!!!

    FYI, I added an h3.widgettitle to it, which I think is a nice touch:

    $default_sidebar = false;
    				$parent = get_the_title($post->post_parent);
    				$parentlink = get_the_permalink($post->post_parent);
                    $sidebar_menu .= "<nav class='widget widget_nav_menu $display_child_pages'><ul class='nested_nav'>";
    				$sidebar_menu .= "<h3 class='widgettitle'><a href='{$parentlink}'>$parent</a></h3>";
                    $sidebar_menu .= $children;
                    $sidebar_menu .= "</ul></nav>";
    #385301

    Hi!

    Glad it is working now. :)

    Regards,
    Ismael

    #511597

    Thanks for this thread. It would be fantastic if this option was part of the theme admin somehow. Those sidebars look so much better with the title/parent page.

    #511936

    Hi @torndownunit,

    Thanks for the feedback, we’ll see what we can do about that.

    Regards,
    Rikard

    #722238

    Hey guys, I’m using this code you gave me on another site, but this site has some third level pages and, when I’m in one of those third level pages, the sidebar menu title changes to the parent of those third level pages — I need it to stay as the title of the section; the top level nav item; much more standard.

    For example, on http://besanthill.wpengine.com/academics/sustainability/calendar-and-news/ (hosted on WPengine) the menu title should be Academics, not Sustainability Education.

    Would you mind showing me what I have to tweak to achieve that?
    Thanks!

    #722405

    Hi!

    please open a new ticket in our support forum, instead of posting in a very old thread about it.
    Send us admin access, so we can have a deeper look into it.

    Regards,
    Andy

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘add titles to sidebar navigation’ is closed to new replies.