The Lucas Problem puzzle was my first CGI program. I showed this puzzle to every person I met in 1995, who was connected to the Internet :).
Along Comes WordPress
I wanted an interactive blog. First, I tried Pebble before WordPress, because I am a Sun Certified Java Programmer, and Pebble is written in Java.
I had to learn PHP for WordPress. PHP was easy to learn, because it is based on C.
Each document on my homepage included keywords, and a description for search engines. WordPress is not shipped with a feature to add this information. I compensated with multiple categories. Who knew? I replaced my keywords with categories, until I learned how to write a plugin that added keywords and description to document headers.
Where’s the Tags?
Google uses categories and tags to determine search results. See the rich snippets on this page for an example.
A WordPress post should have 1 category and 1 or more tags. I noticed that my old posts had multiple categories recently. This is how I fixed it.
How to Find Posts with Multiple Categories
I wrote a PHP function to check a WordPress blog for posts with multiple categories. It can be used as a standalone page.
Code is available from my first Github Gist, and included below. I will explain a few lines.
Line 29 reads the IDs of all published posts.
Line 40 uses get_the category() to read a post’s categories
Finally: Line 42 tests for multiple categories
Updated November 28, 2014
- Removed Exceptions.
- Ignore unlikely post without a category.
- Display message if no posts were found.
How to Test Your WordPress Blog
Another Way to Test Your WordPress Blog
Gregory Karpinsky shared info about an alternative version, after I shared my Gist on Google+.
Siniša Kolundžić used more SQL, and got a different result. See How to count posts in multiple categories for WordPress for his version.
It does not matter which program you use to remove multiple categories from your WordPress posts.
But do it now, for better search results and a nicer interface for your blog’s visitors.