Assigning posts to taxonomy terms in XML-RPC:
Let’s assume your setup is:
xml-rpc
wp.newPost
(sender) site A -------------> site B (receiver)
and you want to assign the new posts to a given taxonomy terms on site B.
From site B:
Then you can try the following, on the receiving site B:
$post_data['tax_input'] = array( 'category' => array( 207 ) );
where the category
taxonomy with id 207
already exists on the site B
.
It’s also possible to use the other supported parameters of wp_insert_post()
, like post_category
or tags_input
. In your case you could therefore also use:
$post_data['post_category'] = array( 207 );
From site A:
Notice that the terms
and terms_names
parameters are supported by the payload of the wp.newPost
query, from the sending
site A.
Here’s an example for the site A, how one could add terms of a given taxonomy:
$result = $client->query(
'wp.newPost',
array(
$blog_id,
$user,
$password,
array(
'post_status' => 'draft',
'post_title' => 'Test',
'post_content' => 'We are testing XML-RPC!',
'terms_names' => array(
'post_tag' => array( 'xml-rpc' ),
'category' => array( 'wordpress-testing' ),
),
)
)
);