Moving from Tumblr to WordPress

Recently I moved this blog from Tumblr to WordPress, as I wanted more control over the environment. My setup now is a hosted WordPress instance on heroku, with really nothing special, using the current PHP stack with Apache2 as my server, and ClearDB to provide me a MySQL instance to store data in. Since this basic setup will provide rather dreadful performance, especially on a single free Dyno, I use Amazons CloudFront as my CDN. All this gets me to a quite fast experience. The setup was quick and painless, but migration of the content proved harder than expected. All there is to do to make this work on heroku is using environment variables to get the database setup in PHP.

https://gist.github.com/sideshowcoder/251bfe82128958901c20.js

Importing Tumblr into WordPress

WordPress offers an importer for Tumblr, sadly this importer seems to strip HTML from Tumblr posts which meant that all my carefully embedded content was not imported. Looking around there are multiple ways to solve this, the quickest being Tumblr2Wordpress which allows to create a WordPress compatible XML file from all the Tumblr posts, with the content being HTML. Importing is as simple as hitting import on the new WordPress blog.  

One thing which constantly annoys me on the more “casual” web is that people break links all the time, and since I didn’t want to be one of those people I wanted to make sure that all links to my content still work after the migration. Also since I use Disqus for my commenting, and Disqus uses the URL to determine the correct comment stream (afaik) I wanted to make sure this works correctly. Tumblr uses a somewhat weird way to reference posts its URL format is something like: http://tumblr.com/posts/SOME_ID/THE_SLUGIFIED_POST_TITLE what is funny about this is that the last part of the URL does not matter at all, it is just the ID Tumblr cares about, and this ID is also carried over by the import and stored in the post_name attribute for the post. So to faking the first part of the Tumblr URL in WordPress is easy, just make the permalink structure: /post/%postname%. Now if everybody would just link to the ID this would work great, but sadly most of the time the title is going to be included, even though nobody cares about it. The solution to this is simple, just don’t make WordPress care about it either, but display it if needed.https://gist.github.com/sideshowcoder/6c57a8fa85c28e9a837b.js

Added to function.php of the theme that is in use, this little snippet will provide a new tag for the permalinks to attach and strip of the slugified title to the to the permalinks, depending on if the imported post used the Tumblr way of URL or if it is a new WordPress post, just don’t name your posts 1234… /post/%postname%/%tumblrslug% will now give you the structure you need.

Easy management with Rake

For the longest time I have been a ruby guy and I just like to use rake to automate almost everything and do the needed command remembering for me. So to make sure I can keep managing my blog I ended up creating a Rakefile with some function to manage my remote instance, and I use dotenv to manage my local variables in the same way as heroku does remotely, through environment variables. For anybody interested, this is what this looks like

And that’s it, the blog is migrated, all the links should still work and I can easily manage the needed tasks, like backup, getting into the database, running a local server all through Rake.

Pressevent alpha, WordPress update tracker

Over my time running and administrating WordPress for various reasons I became
annoyed with always checking which instance is at which version, and should be
updated. Most of the time updating all at once is just not practical, but
keeping installations at an old version is dangerous, so here we go:

Pressevent watches all the WordPress
installs I have and sends me a report every night if updates are available for
any of my installations. Since there is no clean API for this it requires a
plugin to be installed but this should be easy for every WordPress user right
;).

Currently this is still early since it mainly was a quick weekend project to
make my own life easier, but maybe it’s helpful to others.

Enjoy!

WordPress Plugin: WordPress Page Contact

Since WordPress does not provide any kind of author widget to go along with a post or page I decided to roll my own. I feel like it’s a nice thing to get the contact details for a person responsible for a specific section of the page right on this page, and a widget seemed like a perfect fit, so this is how WordPress Page Contact came into being, as my first listed WordPress plugin.

The structure is rather simple: create a database of contacts and associate them to a page or post via postmeta, which can be retrieved easily upon display. Rollup the information in a widget to display in the sidebar for any given entry and here we go.

Since I didn’t find anything similar I decided apply for it to be listed in the Plugin index so here we are. You can find it as WordPress Page Contact.

Enjoy!

Use a different single template per category in WordPress

In a recent WordPress project the posts are displayed on different pages differentiated by category instead of type. In this case different designs are loaded based on categories as well, since the theme needs to match the design of the current page. WordPress does not provide a build in mechanism to do this, it only does for post types.

The solution is rather simple, use the single.php file to first check the category and load the matching template. Since in my development environment the categories might match to different IDs than in the deployed instance it’s more practical to match by name instead of ID. Importantly first the category ID needs identification by name, and is stored to load the matching template, since matching via the $post variable can only be achieved via ID not name or slug. For anybody interested I put example code up on github.

https://gist.github.com/1272148.js