It wasn’t too ugly. But it wasn’t exactly a cool swim either. I thought I would jot down why and how I moved from using a Custom Post Type for each type of post that I publish here — status, photo, audio, and normal post — to Post Formats.
First, why move to Post Formats from Custom Post Types? For my use, Post Formats make much more sense than creating my own Custom Post Types with their own taxonomies. In November 2011 Matt Mullenweg described Post Formats in this way when releasing WordPress 3.1:
our new Post Formats support which makes it easy for themes to create portable tumblelogs with different styling for different types of posts
I remember my reaction to Post Formats at the time. It did seem like a great way to allow those that liked Tumblr’s simple post format style, that of being able to quickly share an image or quote rather than a full blog post, using WordPress. But in reality, as Post Formats matured over subsequent releases I believe their utility has gone far beyond just that of competing with another platform’s ease of styling as Matt’s original description laid out. I think this bit from the WordPress Codex describes their value better:
The standardization of this list provides both compatibility between numerous themes and an avenue for external blogging tools to access this feature in a consistent fashion.
This is the important bit. Standardization. My Custom Post Type for statuses, while similar to the status Post Format, wasn’t standardized and wouldn’t be compatible if I switched themes, used the WordPress iOS application, or tried to use them with the thousands and thousands of plugins that support Post Formats. So they looked like statuses but they didn’t have the advantage of WordPress’ built-in status format.
If you have a site like mine where I’m attempting to share from my site first then onto the social networks (POSSE), you will likely need the very same Post Formats that I do. And so will everyone else. To standardize these specific formats allows them to become much more powerful than simply styling them in a theme.
This important bit about standardization was the WordPress development team’s exact stated purpose for the feature. In fact, the implementation of Post Formats didn’t even start out as feature. It was simply to be "a standard" to be documented in the Codex. Andrew Nacin just prior to WordPress 3.1’s release wrote:
There was no code. It was simply going to outline a standard: a name for a custom taxonomy, and a standardized set of formats.
I urge you to read the post he wrote at the time. Fascinating look back to just 5 years ago.
So, this is why I ditched my own Custom Post Types. Since I was converting my site from Barley (which used Content Types in a similar way to Custom Post Types) I ended up coming with that overall "baggage" of customizing each type for my need. When, in reality, the core team had already figured out the subtle nuances between the formats that I was going to use and have already standardized their use, their API, and (optionally) their display.
How did I convert all of my posts into blog posts and then change their format?
One of the advantages to using WordPress at all is that there are myriad developers out there attempting to solve the same issues you will likely come across. In this way you’re able to find their solution and either use it outright (and hopefully support them financially or in some other way) or stand on the shoulders of their code and customize it for your needs. So when I decided that I wanted to make this switch the first thing I looked for was a plugin that would help me change my Custom Post Types into blog posts en masse.
John James Jacoby is the lead developer of a plugin called Post Type Switcher. Essentially this plugin makes it very easy to change many Post Types into a blog post in a matter of a few minutes. Once installed and activated you’re able to "bulk edit" all posts listed in your Admin to change their Post Type. Since I only had a few hundred status updates, a few dozen photos, and very few audio bits that I’ve published so far moving these was easy. From there, I bulk edited those posts to change their Post Format to the appropriate ones. It took about a half-an-hour and a few dozen clicks.
Yes, I could have written a quick script to do it. It would be fairly simple to loop through all Custom Post Types and run wp_update_post to switch the post_type. And I thought about that. But why reinvent the wheel? JJJ’s plugin worked beautifully for my needs. However, if I had thousands and thousands of posts to convert, I likely would have avoided the mouse at all costs and written that script.
Once the posts were converted into blog posts and their format adjusted I was able to remove all of the Custom Post Type code that I had written, their associated archive and single files and a bunch of query adjustments too. Switching to Post Formats simplified my theme’s code fairly dramatically.
I have run into a bit of an issue though. And one that I’m still wrestling with.
I wanted a way for viewers of the site to filter the Post Formats separately. So if they wanted to read my latest blog posts or sort through my statuses they could do so. WordPress has a way to do this out-of-the-box (almost). You can filter blog post types by using /type/post-format-name-here*. However, the one Post Format that cannot be filtered, as far as I’ve been able to tell, are normal blog posts (which WordPress calls "Standard"). For some reason, it does not mark these posts with a format but rather leaves those null. So /type/standard does not return your posts it simply results in a 404.
Others have discovered this same caveat to Post Formats and have written about it. Here is a Stack Overflow thread from 2012, as an example. The solution suggested there was similarly suggested in April 2011 (before 3.1 was released) by "levin" on their blog. At the end of their post they wrote: "I hope there have a better solution in future WordPress release".
As far as I can tell, there hasn’t been. I’ve tried several different URL hacks and rewrites and so forth to see if somehow WordPress could filter out just the Standard Post Format out-of-the-box and I haven’t been able to force it to do so. I plan on digging into this a bit more but for now I’ve used a solution similar to levin’s from 2011 to filter my posts. It is a crufty URL for now too. Because hopefully the ugliness of the URL will spur me on and motivate me to create a more elegant solution. When I do I’ll share it on my blog.
*I think having /type in this URL is a bit confusing at this isn’t a custom post type. It should likely be /format?