• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2662

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

Add Published Post Count After WP Nav Menu Items

This code, once added to your child themes functions file, displays the post count in your nav menu.

Every time you publish a new post, it dynamically updates and also changes if you delete a published post.

You can change the primary in the code to secondary or any other nav menu location.

You can also change the text to anything you like and modify the functions parameters.

Register for full access

You could also replace the last-child structural pseudo-class with last-of-type.

The only issue you may have is with the CSS class your theme uses.

Based on testing the code in different themes, i found the best way to work out which class to use is to inspect the output and try the different classes your theme generates.

Related Code

  • Replace Site Tagline With A Dynamic Published Posts Counter

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

PHP Code

template_include

get_body_class

if else

array

class_exists

foreach

sprintf

add_action

printf

variable

Advertise · WPEngine · Genesis · Log in

  • How Premium Membership Works
  • Sign Up
  • Support
  • Subscription Details/Invoice
  • Tagged Tutorials
  • Access-Download Problems