-
-
Save Roy-Oto/6d07b5579cdfc8c0d1421b7c1ae345a6 to your computer and use it in GitHub Desktop.
How to display the number of items in a category (add square bracket)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wp_nav_menu_objects','my_nav_count'); | |
function my_nav_count($items){ | |
foreach ($items as $item){ | |
if($item->object == 'category'){ | |
$item->title .= " [". get_term($item->object_id,'category')->count ."]"; | |
$args[] = $item; | |
} | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment