• Hello all,

    Here’s my patch for post.php for wp.newPost and wp.editPost of the wordpress xml rpc api not taking into account correctly the ‘post_thumbnail’ … With this fix, attaching a thumbnail will work exactly like wp.uploadFile attaches an image to a post.

    --- /Users/karim/Desktop/post.php	2015-05-06 16:21:30.000000000 +0200
    +++ /Users/karim/Desktop/post 2.php	2015-07-25 12:59:32.000000000 +0200
    @@ -1,6 +1,6 @@
     <?php
     /**
    - * Post functions and post utility function.
    + * sst functions and post utility function.
      *
      * @package WordPress
      * @subpackage Post
    @@ -5848,9 +5848,16 @@
     	$post = get_post( $post );
     	$thumbnail_id = absint( $thumbnail_id );
     	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
    -		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
    +		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) ) {
    +
    +			$my_post = array(
    +      				'ID'           => $thumbnail_id,
    +      				'post_parent'   => $post->ID
    +  			);
    +			wp_update_post( $my_post );
    +
     			return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
    -		else
    +		} else
     			return delete_post_meta( $post->ID, '_thumbnail_id' );
     	}
     	return false;
    @@ -5931,4 +5938,4 @@
    
     		update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache );
     	}
    -}
    +}
    \ No newline at end of file
  • The topic ‘Fix for wp.newPost and wp.editPost not attaching thumbnail’ is closed to new replies.