Editing WordPress “Pages” Via XML-RPC

WordPress‘s Pages open the door to using WP as a content management system. Unfortunately, Pages can’t be edited via XML-RPC blogging apps like Ecto. This might be a good thing, but I’m foolhardy enough to try working around it.

Here’s how:

Find a text editor you like and open up the wp-includes/functions-post.php file.

in the wp_get_recent_posts() function, change this:

$sql = “SELECT * FROM $wpdb->posts WHERE post_status IN ('publish', 'draft', 'private') ORDER BY post_date DESC $limit”;

to this:

$sql = “SELECT * FROM $wpdb->posts WHERE post_status IN ('publish', 'draft', 'private', 'static') ORDER BY post_date DESC $limit”;

Now, in the wp_update_post() function, look for this block of code:

// Escape data pulled from DB.<br /> $post = add_magic_quotes($post);<br /> extract($post);

and insert this block underneath it:

// XML-RPCs apps can't return “static” post status,<br /> // so we have to work around it<br /> $page_status = NULL;<br /> if($post_status == “static”)<br /> $page_status = “static”;

And follow that up by looking for this block:

// Now overwrite any changed values being passed in. These are<br /> // already escaped.<br /> extract($postarr);

and insert this block underneath it:

// set post_status static if this is a page<br /> if($page_status)<br /> $post_status = $page_status;

Fair warning: this works in my limited testing, but don’t blame me if you try it and it breaks something. You’d be a fool to mess with this on a live install, so don’t.