Categories
WordPress Tips

Display Count of Published Posts In Native WordPress Text Widget

My home page displays a count of published posts which i was updating manually each time i published a new one.

In this post, i’ll provide the PHP code which you can simply add to a text widget so it automatically updates.

post count

The code also includes a widget_text filter that executes PHP code in any native text widget.

Best to add the custom function to your child themes functions file before adding the one line of text with PHP code in a widget.

Leave a Reply

Your email address will not be published. Required fields are marked *