Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
August 21, 2017 at 6:56 pm #842170
I created a menu that I’m using on a side bar for a section of my website. I would like the parent page to be a link (different text treatment than the child pages however). So far I have the following custom function…
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 .= get_the_title($parent); $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; } }
… and would like to know how I can make the menu title also a link while retaining the existing style? I’ve attached some additional info, thank you.
August 24, 2017 at 2:55 pm #843523Hey lzevon,
Try to replace this part of your code:
$sidebar_menu .= get_the_title($parent);
to this one:
$sidebar_menu .= '<h2 class="custom-sidebar-title"><a href="' . get_permalink($parent) . '">' . get_the_title($parent) . '</a></h2>';
then add this css code on your Quick CSS (located in Enfold > General Styling):
#top .sidebar h2.custom-sidebar-title a { font-size: 18px; color: #3c7c21 !important; }
Hope this helps :)
Best regards,
NikkoAugust 24, 2017 at 3:27 pm #843540Nikko, thank you!
August 24, 2017 at 5:10 pm #843595Hi,
Glad we could help. Let us know if you need more assistance :)
Best regards,
Nikko -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- The topic ‘Link sidebar menu title to page’ is closed to new replies.