Order WordPress Posts by Most Comments


The Logo for WordPress.

I take great delight in seeing people reply to my blog posts. I use WebMentions to collect replies from social media and other sites. But which of my posts has the most comments? Here's a snipped to stick in your functions.php file. It allows you to add ?comment-order to any WordPress URl and have the posts with the most comments on top. // Add ordering by comments add_action( 'pre_get_posts', 'pre_get_posts_by_comments' ); function pre_get_posts_by_comments( $query ) { // Do nothing if …

Continue reading →

Is WordPress.org GDPR compliant?


39 people reacted with 💯. 12 with ☝.

A few weeks ago, I got a chance to speak truth to power. I used my WordPress.org account to sign in to the official WordPress.org Slack where the various WordPress dramas were being discussed. After a brief chat about the latest shenanigans, I publicly replied to the CEO: Here's a link to the full exchange There was no reply forthcoming - although, as you can see, my message gathered a fair few positive reactions. As was inevitable, the next morning I found myself locked out of the Slack.…

Continue reading →

Change WordPress Fragment Links in RSS Feeds to be Permalinks


A glowing red mushroom cloud caused by an atomic bomb.

Here's a knotty problem. Lots of my posts use URl Fragments. Those are links which start with #. They allow me to write: <a href="#where-is-this-a-problem>Jump to heading</a> So when someone clicks on a link, they go straight to the relevant section. For example, they might want to skip straight to how to fix it. Isn't that clever? Where is this a problem? This works great when someone is on my website. They're on the page, and a fragment links straight to the correct section of that…

Continue reading →

Using phpList for a blog's newsletter


RSS Settings Screen.

Some people like to receive this blog via email. I previously used JetPack to send out subscriber messages - but it became increasingly clear that Automattic isn't a good steward of such things. I couldn't find any services which would let me send a few thousand subscribers a few emails per week, at zero cost. So, redecentralise! I installed phpList which is an open source email campaign tool. My webhost - Krystal - had a one-click install option. But, phpList isn't quite one-click for…

Continue reading →

WordPress - Sic Transit Gloria Mundi


The Logo for WordPress.

Why do so many vastly-wealthy tech personalities go mad? My ideal job involves being employed by a millionaire tech-bro. Just before they get on stage, or moments before they file a lawsuit, or an instant before they publish their thought leadership - I will appear to them. I will be dressed in rags, body smeared with excrement, weeping sores blotching my face. I will sidle up to them, lean down, and whisper into their ear "Sic Transit Gloria Mundi!" This used to be the way, of course. When a …

Continue reading →

Import JetPack Statistics into Koko


Graph showing page views over time.

I've quit JetPack stats. I've moved to Koko Analytics. All the stats code is self hosted, it is privacy preserving, and the codebase is small and simple. But I am vain. I want all my old JetPack stats to appear in Koko so I can look back on the glory days of blogging. Koko has two main tables. The first is a summary table called wpbp_koko_analytics_site_stats : date visitors pageviews 2009-10-30 25 47 2009-10-31 70 86 2009-11-01 61 72 That's the total…

Continue reading →

Liberate your daily statistics from JetPack


Bar chart showing how many times a blog has been red over a year.

Because Ma.tt continues to burn all of the goodwill built up by WordPress, and JetPack have decided to charge a ridiculous sum for their statistics, I've decided to move to a new stats provider. But I don't want to lose all the statistics I've built up over the years. How do I download a day-by-day export of my JetPack stats? Luckily, there is an API for downloading all your JetPack stats! First, get your API key by visiting https://apikey.wordpress.com/ - it should be a 12 character…

Continue reading →

How to make Markdown Footnotes start at Zero in WordPress


The Logo for WordPress.

As a dedicated and professional computer scientician, I believe that all indices must start at zero. Not one, not two, but zero. The zeroth element is sacrosanct to our creed; for in the beginning there was nothing. If you're using WordPress's JetPack, it uses an ancient version of Markdown Extra. You can either monkeypatch this, or install a separate Markdown plugin. I've patched my fork of it in two specific places. Firstly, I set $this->footnote_counter = 0; in the initial config of the …

Continue reading →

WordPress - Display hook action priority in the dashboard


List of actions with various priorities.

If your WordPress site has lots of plugins, it's sometimes difficult to keep track of what is manipulating your content. Ever wondered what priority all your various actions and filters have? This is a widget which will show you which actions are registered to your blog's hooks, and their priority order. It looks like this: Stick this code in your theme's functions.php or in its own plugin. function edent_priority_dashboard_widget_contents() { global $wp_filter; // Change this to …

Continue reading →

Liberate your Markdown posts from JetPack in WordPress


JetPack Markdown switched off.

A scrap of code which I hope helps you. Problem You installed the WordPress JetPack plugin and wrote all your blog posts in Markdown. Now you want to remove JetPack or replace it with a better Markdown parser. You turn off JetPack's "Write posts or pages in plain-text Markdown syntax". You click edit on a post and see the HTML version of your page. Where did the Markdown version go? Background When you write using JetPack's Markdown plugin, the Markdown version is stored in…

Continue reading →

Replace Twitter Embeds with Semantic HTML


Tweet from me in 2009. "Ah. I appear to have spent the majority of the night playing World Of Goo What an addictive little game."

I logged into Twitter using a fresh account last week. No followers, no preferences set. The default experience was an unending slurry of racism and porn. I don't care to use Twitter any more. Whatever good that was there is now drowned in a cess-pit of violent filth. I still have a lot of Tweets embedded on this blog. Using WordPress, it was easy to paste in a link and have it converted to an embed. But I don't want to direct people to a dangerous site. So here's a somewhat automated way to …

Continue reading →

Remove unnecessary closing slash on get_the_post_thumbnail() in WordPress


The HTML validator showing lots of info messages.

I am a pedant. I like it when validators say "nothing to report". No errors, no warnings, no information messages. My blog is plagued with messages on the HTML validator saying Info: Trailing slash on void elements has no effect and interacts badly with unquoted attribute values. By default, the WordPress function get_the_post_thumbnail() spits out HTML like: <img width="1024" height="593" src="example.jpg" alt="whatever" /> That final / is unnecessary. Having it there…

Continue reading →