Tagged: Sidebar Menu
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
June 11, 2015 at 8:05 pm #458006
Hello,
I would like to add “count” of posts under sub categories (in parenthesis) to a nested sidebar menu like;
-Category
– Sub Category A (5)
– Sub Category B (3)I had found a code by your moderator (“DUDE”) to modify nested sidebar menu and added into my functions.php ;
(I’m not sure if it’s necessary)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; }Thank you
June 12, 2015 at 8:42 pm #458612It would be much more useful as custom widget I guess for other users as well, looking for a solution from moderators and developers.
Thank you,
Best Regards.June 12, 2015 at 10:20 pm #458644Please someone answer
June 13, 2015 at 2:13 pm #458756Still no answer?
June 16, 2015 at 3:37 am #459790Hi,
Can you post the link to your website? there’s a native WP function that let you do this:
https://codex.wordpress.org/Function_Reference/wp_count_termsRegards,
Josue -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
