Editing Wordpress pages using blogging tools

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.

7 Comments

  1. Posted July 5, 2009 at 5:29 pm | Permalink

    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.

  2. Posted July 5, 2009 at 5:42 pm | Permalink

    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.

  3. Posted July 5, 2009 at 5:47 pm | Permalink

    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.

  4. Posted September 30, 2009 at 10:28 am | Permalink

    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…

  5. Posted January 11, 2010 at 1:02 pm | Permalink

    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

  6. Simon
    Posted January 11, 2010 at 1:11 pm | Permalink

    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.

  7. Posted February 8, 2010 at 3:02 am | Permalink

    Thanks, Simon. I’ll update the original post.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*