Created
May 28, 2013 23:58
-
-
Save blainsmith/5667031 to your computer and use it in GitHub Desktop.
Modify post type when using XML-RPC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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