Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #575658

    Hi. I followed the instruction on this thread: https://kriesi.at/support/topic/show-parent-page-above-nested-subpages-in-sidebar-navigation/ but the parent is not hyperlinked like the children are. How can I make the Parent active?

    Thanks!

    #576243

    Hi laptophobo,

    Could you provide us with a link to the site in question so that we can take a closer look please?

    Regards,
    Rikard

    #576260

    Hi Rikard,

    I should have supplied that earlier. Here it is. (In private content.). You see that the sidebar link About Us, which is the parent, isn’t active.

    Thank you,

    #577869

    Hey!

    Please add the below css in Enfold > general > Quick CSS

    
    /* Main menu active link */
    li.current-menu-item {
      /* ADD YOUR CSS STYLES FOR ACTIVE MENU HERE*/
    }
    

    Regards,
    Vinay Kashyap

    • This reply was modified 8 years, 9 months ago by Vinay.
    #578226

    Hi Vinay. The problem is not how to style that Parent, but to make it an active link.

    If you go to that page, you’ll see that on the left sidebar is the Parent “About Us”. When you try to click it, you’ll see that it’s not active like it’s children below. I wish to make the Parent (About Us) an active link–going to the About Us parent page.

    #579147

    Hi!

    Replace the parent line with this:

    $sidebar_menu .= "<a href='". get_the_permalink($parent) ."'>".get_the_title($parent)."</a>";
    

    Cheers!
    Ismael

    #579321

    Thanks for the work on that Ismael. Your edit to the code has made it active, but it’s adding extra space bottom padding to it.

    Here’s the updated code in its entirety:

    /* adds the parent page in sidebar navigation */
    
    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 .= "<a href='". get_the_permalink($parent) ."'>".get_the_title($parent)."</a>";
    			$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; }
    }
    
    #580186

    Hi!

    Remove the top padding with css:

    .widget_nav_menu {
        padding-top: 0;
    }

    Best regards,
    Ismael

    #580340

    Thanks much. All looking right now.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Show parent page above nested subpages in sidebar navigation’ is closed to new replies.