Lets say you want to post from your Android or Iphone WordPress clients to a custom post type instead of the the defualt ‘post’ type. Paste the code below in your functions.php
and you should be good to go 🙂
function redirect_xmlrpc_to_custom_post_type ($data, $postarr) {
$p2_custom_post_type = 'custom_post_type'; //Change this to the custom post type you are using for your blog
if (defined('XMLRPC_REQUEST') || defined('APP_REQUEST')) {
$data['post_type'] = $p2_custom_post_type;
return $data;
}
return $data;
}
add_filter('wp_insert_post_data', 'redirect_xmlrpc_to_custom_post_type', 99, 2);
Change $p2_custom_post_type = 'custom_post_type'
to the custom post type you are using for your blog.
Now I can post from my Android Phone to my custom P2 micro-blog 🙂
Hey, thanks form sharing 🙂
Do you eventually have a solution to list this post-type in the app? This would be awesome! Best regards, Steffen
Your code is broken.
This line needs a semicolon in the end.
$p2_custom_post_type = ‘custom_post_type’
Thanks for pointing that out, I have updated the post.
The code doesnt work anymore.
It gives me a 500 internal error message.
Can you update this post? You are the only one on the web with this sollution. Too bad it is outdated.
@Xander, the code snippet still works for me, not sure why it isn’t working for you.
Don’t you have a idea how this might happen ? When I use the code snippet it gives me a 500 internal server error. I have xmlrpc enabled. Do I need to do something in htacces maybe ?
Can you try this?
Ofcourse you gotta chage ‘custom_post_type’ to the post type you’re using.
No its same – I got the same problem. the method doesnt work if I put this in the functions.php.
BTW I’m using WP 3.2.1
While the changes wouldn’t get overwritten, it only lets you use a custom post type at the expense of not being able to work with actual posts.
True, and I use my desktop blogging application only for my custom post types. However it should be easy to modify it to lets say make it tag based. If you have a tag “custom_post_type” then it will publish as your custom post type or as a normal post otherwise. Your comment went into the spam folder for some reason, akismet doesn’t like you 🙂
@Varun Well they won’t be because the theme for my website is a custom child theme for the hybrid wordpress theme. Infact I always run the svn trunk version of hybrid, so it updates almost every second week. Even the theme for the NSM Website is a child theme I adapted from a old theme by the same developer – Justin Tadlock.
Cool! But is there a more maintainable way to do it? You custom changes will get wiped out in an automated upgrade and will need to be reapplied.
You could also use this plugin. It lets you customize themes through the wp-admin. Even if the theme updates, your customizations will not be affected.