Skip to content

www.rolfje.com

Querying Classicpress database for page hits

Posted on 2025-11-012025-10-21 By rolfje No Comments on Querying Classicpress database for page hits

Now that I am running classicpress, I miss the statistics that I received at wordpress.org. I don’t want to install third party cookies or other adware stuff, so I was looking to see how to solve that completely locally. Here’s how I got it working, withouts ads, all local, for free.

I installed the “WP Post Statistics (Visitors & Visits Counter)” plugin (not the pro version), which immediately starts counting and can show some statistics in the admin dashboard. You can find these statistics in the classicpress database too, so I plan on creating a metrics endpoint so that I can scrape this from my metrics server.

For those interested, this is how you get some of these metrics from the classicpress database (a mariadb database in my case):

select posts.id, posts.post_date, posts.post_title, count(visits.id) as visitcount
from cp_posts as posts
join cp_poststats_visits as visits on posts.id = visits.post_id
group by posts.id, posts.post_date, posts.post_title
order by visitcount desc;

This produces output somewhat like this:

+------+---------------------+-----------------------------------------------+------------+
| id   | post_date           | post_title                                    | visitcount |
+------+---------------------+-----------------------------------------------+------------+
| 1418 | 2011-08-27 14:57:33 | How to fix a Krups XN2001 Nespresso machine   |         14 |
| 2418 | 2024-09-01 17:35:45 | Remove DataTool Alarm                         |         13 |
| 2474 | 2025-10-20 19:54:18 | Gardena Sileno verbindingsprobleem opgelost   |         13 |
| 2392 | 2022-01-30 14:12:06 | Exit WordPress                                |         12 |
| 2358 | 2021-05-23 10:32:10 | When munin df does not list all disks         |          7 |
...

There is even information about countries and cities:

select country, count(*) from cp_poststats_visits group by 1 order by 2 desc;
+-----------------+----------+
| country         | count(*) |
+-----------------+----------+
| The Netherlands |      102 |
| United States   |       20 |
| Spain           |        2 |
| France          |        1 |
| Greece          |        1 |
+-----------------+----------+

I know, the numbers are not impressive yet (welcome back Greece 🙂 ), but this new server has only been up for 2 days after www.rolfje.com being offline for quite some time now. It looks like it will pick up traffic again, as all content is available at the original urls.

Of course there are more tables to explore in your classicpress database (be careful, create backups):

show tables
+----------------------------+
| Tables_in_classicpress     |
+----------------------------+
| cp_commentmeta             |
| cp_comments                |
| cp_links                   |
| cp_object_relationshipmeta |
| cp_object_relationships    |
| cp_options                 |
| cp_postmeta                |
| cp_posts                   |
| cp_poststats_visits        |
| cp_term_relationships      |
| cp_term_taxonomy           |
| cp_termmeta                |
| cp_terms                   |
| cp_usermeta                |
| cp_users                   |
+----------------------------+

Have fun digging around!

Software, Uncategorized Tags:blog, classicpress, programming, wordpress

Post navigation

Previous Post: Gardena Sileno verbindingsprobleem opgelost
Next Post: Finding HomeAssistant Entities in Prometheus

Leave a Reply Cancel reply

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

         

Recent Comments

  • rolfje on Exit WordPress
  • rolfje on Methode Buijs uitgelegd
  • LinkedIn is at Peak Enshittifaction – Will Chatham's Blog on Linked-In not really Opt-in?
  • Hans j on 1N4148 diode as RF switch
  • Roaming Rhonda on DLNA on OSX, done right

Tags

Apple backup design DIY DRM eclipse environment Fun Garmin GForge gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Kawasaki Keynote modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software T-Mobile technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (105)
  • Divorce (1)
  • Electronics (3)
  • Fun (57)
  • Games (7)
  • Hardware (72)
  • Microsoft (18)
  • Racing (14)
  • Software (135)
  • Uncategorized (68)
  • Workshop (20)

Archives

Brought to you without adds, banners, cookies or tracking. This one is on me. Yes, life can be this good. Pay it forward.

Copyright © 2025 www.rolfje.com.

Powered by PressBook WordPress theme