Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Source:
- https://gist.github.com/generatepress/050648ac7d2d566865ac
- Paste this code in function:
- add_filter('the_title', 'generate_category_post_count_title', 10, 2);
- function generate_category_post_count_title($title, $post_ID)
- {
- if( 'nav_menu_item' == get_post_type($post_ID) )
- {
- if( 'taxonomy' == get_post_meta($post_ID, '_menu_item_type', true) && 'category' == get_post_meta($post_ID, '_menu_item_object', true) )
- {
- $category = get_category( get_post_meta($post_ID, '_menu_item_object_id', true) );
- $title .= sprintf(' (%d)', $category->count);
- }
- }
- return $title;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement