Skip to content

Instantly share code, notes, and snippets.

@blainsmith
Created May 28, 2013 23:58
Show Gist options
  • Save blainsmith/5667031 to your computer and use it in GitHub Desktop.
Save blainsmith/5667031 to your computer and use it in GitHub Desktop.
Modify post type when using XML-RPC
function redirect_xmlrpc_to_custom_post_type ($data, $postarr) {
// This function detects a XML-RPC request and modifies it before posting
$p2_custom_post_type = 'FanPost'; // Define your Custom post type
if (defined('XMLRPC_REQUEST') || defined('APP_REQUEST')) {
$data['post_type'] = $p2_custom_post_type; // sets the request post type to custom post type instead of the default 'Post'.
return $data;
}
return $data;
}
// Add the filter
add_filter('wp_insert_post_data', 'redirect_xmlrpc_to_custom_post_type', 99, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment