Editing WordPress pages using blogging tools
February 26, 2009
I’m a heavy user of TextMate, and use the blogging bundle to create and edit posts. I’m also a heavy user of WordPress Pages that enable wordpress to be used as a CMS. The one issue that always bugs me with any new WordPress installation is that you cannot edit pages from XML-RPC blogging tools like TextMate, Ecto, Windows Live Writer and such. The only working solution I’ve found to the same is a little ugly: You’ll need to edit one of the core wordpress files. I wouldn’t do it if I didn’t love TextMate so much.
This post from Maison Bisson described the process of editing the files for a previous version. The good news is, for the latest WordPress releases (I’ve checked 2.7.0 and 2.7.1), the data model has been changed to remove the “static” post status for pages (They now have the same status codes as posts), which means that no changes are required to the update fundtion; and a field called post_type now stores information about the kind of post (blog post, page, attachment).
So, essentially, here’s all you need to do to magically get the list of latest posts AND pages on your blogging client:
Modify this query in wp_includes/post.php:
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC $limit";
to this:
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' OR post_type = 'page' ORDER BY post_date DESC $limit";
This is a scotch-tape solution that’s worked well for me so far. Try it at your own risk. Also, remember that when you update your WordPress installation, these changes might get overwritten.
UPDATE: This works for 2.9.1 too, see comments below.
Sameer, not sure when you wrote this, but I’ve been using Windows Live Writer for some time now to compose and edit WordPress pages. It works very well for that.
Thanks for pointing that out, Jeremy. I haven’t used WLW in a while so didn’t know about it. I’m now curious as to how Windows Live Writer does it – I mean, if it does it, there has to be some API exposed somewhere that the TextMate bundle I use is not aware of.
Sameer, good question, and I’m not quite sure. I notice that Zoundry also supports WordPress pages but I’ve not been able to include tags with them, despite the apparent feature.
Awesome! I’ve been looking for a way to do this! Now I can edit my pages in Texmate. Hope it won’t break anything else…
Hi Sameer,
How would I do this with WP 2.9.1 which now reads:
$sql = “SELECT * FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status IN ( ‘draft’, ‘publish’, ‘future’, ‘pending’, ‘private’ ) ORDER BY post_date DESC $limit”;
Can I add the ‘OR post_type = ‘page”?
many thanks
Hi Sameer,
Pleased to report his works on WordPress 2.9.1 and all my pages appeared in Marsedit. I edited on and the changes appeared on my WordPress site.
thank you soo much, I’d been trying to find an answer to this for the past 2 hours.
Thanks, Simon. I’ll update the original post.
Doesn’t seem to work with WP 3.0.1
I used:
$sql = “SELECT * FROM $wpdb->posts WHERE post_type = ‘post’ OR post_type = ‘page’ AND post_status IN ( ‘draft’, ‘publish’, ‘future’, ‘pending’, ‘private’ ) ORDER BY post_date DESC $limit”;