Fixing missing categories and tags in WordPress’ block editor

For several months now, I’ve noticed that the Categories and Tags widgets were missing in my WordPress’s post block editor. It was sort of fine because I could work around it by assigning categories and tags through the Quick Edit functionality from the post list, but it was an annoyance.

I had done the usual debugging steps of disabling plugins, changing to the default theme, even reinstalling the core WordPress code, but nothing changed. I had tried searching online for phrases like “wordpress categories and tags missing” but didn’t come up with anything.

Today, I found two clues that led me to investigate this further. First, when I popped open Chrome’s developer tools, I noticed that the AJAX requests were firing nonstop. I was originally wanting to check whether there were errors in any of the requests, but the requests were all returning JSON responses, so there wasn’t any error in the processing aspect.

Second, I installed the Health Check & Troubleshooting plugin. When I ran it, it showed:

The REST API did not behave correctly

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

The REST API did not process the context query parameter correctly.

I happened to come across this blog post which suggested adding the following piece of configuration to the nginx configuration.

location ~ ^/wp-json/ {
    rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}

Lo and behold, it solved the problem! I haven’t dug into the details as to what exactly is going on. I’m just posting this in case other people come across this issue since it was not straight forward to find the resolution to this problem.

How did advertisements get on my site?

I should probably pay more attention to my own site.

While I was working on my blog last week, I noticed that there were advertisements showing up in the Related Content links at the bottom of all my posts.  I was quite shocked as I never added them intentionally.  I feared that my blog was hacked.

Digging just a little deeper, I quickly found the culprit: the Shareaholic plugin.  I used it for related content and the social sharing buttons for the posts.  It turns out a few months ago they sneakily added in monetization options in their plugin update without having blog owners explicitly opt-in.  That means once you updated the plugin (if you’re using the WordPress panel to do this, there’s pretty much no changelog or notice), ad links would spontaneously spawn on your site.  I guess if you’re a better blog owner you would have caught it sooner than I did.  I understand developers need to make money too, and I’d understand forcing advertisements on the admin panel, but having advertisements enabled by default on the public site is a very sneaky process.

Needless to say, Shareaholic has since been removed from my site.  If you’re still using Shareaholic, you should really review its settings to make sure it’s doing what you want it to do.  For me, I’ve found other plugins to replace the functionality including Floating Social Bar and Contextual Related Posts.

Old blog posts from WordPress 2.6 found and imported

I spent this afternoon digging around my backups, and I was lucky to find my site backup from the end of 2008. I had to find a way to import the posts from WordPress 2.6 into WordPress 3.5.1. Since I had a full site backup, I was able to load the WordPress files and database backup onto my Mac’s local MAMP web development environment (Windows users might use WAMP).

From there, I followed the WordPress upgrade procedure. I upgraded directly from WordPress 2.6 to 3.5.1 directly without a hitch, although it recommended to go version by version. Then with a click of a button, my posts were exported into an XML file. And two clicks later, my posts were imported into my new site. It’s awesome that WordPress has a very easy upgrade and import/export functionality.

I spent a couple hours combing through the blog posts (good memories of high school and university!) making some edits, and fixing links and images.

The only thing now is to find my WordPress backups from 2009-2011. Needless to say:

Update: After a couple hours of digging, I’ve found the backup and have loaded the posts here. The archives here are pretty much complete!