It's all in the title, I'm looking for a way to know if a given post was published through XML-RPC, versus published by hand in the WP admin.

Pseudo code :

if( !wpse_from_xmlrpc( $post -> ID ) {
    // Doesn't come from XMLRPC
} else {
    // Comes from XMLRPC 

You could use a custom field for a post which is saved via XMLRPC by using the action hook xmlrpc_publish_post. wpse_from_xmlrpc() could than check this custom field.

    add_action( 'xmlrpc_publish_post', 'add_xmlrpc_postmeta' );
    function add_xmlrpc_postmeta( $post_id ){
        update_post_meta( $post_id, 'send-by-xmlrpc', 1 );

    function wpse_from_xmlrpc( $post_id ){
        $xmlrpc = get_post_meta( $post_id, 'send-by-xmlrpc', true );
        if( $xmlrpc == 1 )
            return true;
        return false;

More information on this hook can be found in wp-includes/post.php

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.