Easily retrieve WordPress blog statistics 

Happy New Year!

I wanted to kick off the new year with something that I had shared at the end of 2022, which was a break down on the number of blog posts that I have published over the years.

Since @rhjensen was asking about number of blog posts compared to previous years ….

With some quick PowerShell Automation, here’s all my blog post breakdown from 2010-2022 along with the sum, minimum, maximum and average. Sounds like 2015 was an interesting year pic.twitter.com/WIt2KZ34Qa

— William Lam (@*protected email*) (@lamw) December 16, 2022

A number of folks had reached out asking how they could do the same for their own blogs and so I wanted to share the solution that I had used.

The solution that I am using is only applicable for blogs powered by WordPress and is not relavent to other blogging platforms. There are a ton of different ways to retrieve blog statistics from WordPress, including various 3rd party solutions as well as the built-in WordPress stats, but I opted for this solution as I found the default stats system has negatively impacted the performance of my blog due to the volume of traffic and thus I have disabled the default stats collection.

While searching online for an alternative solution that did not require a plugin installation, I came to learn that every WordPress deployment includes a public API endpoint as part of its normal functionality. I browsed the WordPress API Reference and saw that the /posts API would allow me to quickly summarize all of my blog articles.

Note: If you wish to disable your public WordPress API, you can follow this tutorial (using the code snippet option as that is the most recommended over installing a new plugin).

One thing to note is that the Posts API unfortunately does not allow for a high level GET operation, it pulls down the entire blog post and its content, which I would have preferred a filter option that gave only the basic information (e.g. title, date published, etc) and for more details, you could then get the content if needed. In either case, this did not affect the use of the API and everything was pretty snappy and with a bit of testing, I came up with the following PowerShell script:

There are only two variables that you need to fill in, the first is the year in which your blog had started and the second is the URL of the WordPress blog. In the example above, I am checking my buddy Duncan Epping’s blog, the famous yellow-bricks. Due to the maximum results of 100, I have broken the query into first half of the year and second half of the year to aggregate the total number of blog posts and then tallying up along with minimum, maximum and average blog post counts.

Here is the output for running the script above:

As you can see, Duncan is already off strong for 2023 with his first blog post already

Note: If you wish to disable the

I also had some fun checking out some of my other favorite VMware Bloggers, which I had also shared on Twitter:

Having some fun w/Automation & few of my favorite blogs from @DuncanYB @FrankDenneman @CormacJHogan @alanrenouf … just wow, the amount of knowledge that has been shared from these combined over past decade+ is insane!

One person here has been responsible for hiring all of us! pic.twitter.com/himIBxFZfy

— William Lam (@*protected email*) (@lamw) December 16, 2022

This content was originally published here.