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.
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.