-
AuthorPosts
-
February 1, 2016 at 9:32 am #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!
February 2, 2016 at 5:56 am #576243Hi laptophobo,
Could you provide us with a link to the site in question so that we can take a closer look please?
Regards,
RikardFebruary 2, 2016 at 6:55 am #576260Hi 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,
February 4, 2016 at 5:10 pm #577869Hey!
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, 10 months ago by Vinay.
February 5, 2016 at 5:03 am #578226Hi 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.
February 7, 2016 at 9:15 am #579147Hi!
Replace the parent line with this:
$sidebar_menu .= "<a href='". get_the_permalink($parent) ."'>".get_the_title($parent)."</a>";
Cheers!
IsmaelFebruary 8, 2016 at 4:37 am #579321Thanks 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; } }
February 9, 2016 at 8:06 am #580186Hi!
Remove the top padding with css:
.widget_nav_menu { padding-top: 0; }
Best regards,
IsmaelFebruary 9, 2016 at 12:30 pm #580340Thanks much. All looking right now.
-
AuthorPosts
- The topic ‘Show parent page above nested subpages in sidebar navigation’ is closed to new replies.