I want to create new posts with XMLRPC, i was able to edit the Realtionship field with his id only, I want to call the field with his title or other taxonomies.
this is my code in python:
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts
client = Client(my_website, my_username, my_password)
newPost = WordPressPost()
newPost.title = 'test'
newPost.content = 'test content'
newPost.custom_fields = [{'key': 'trailer', 'value' : 'test'}, {'key': 'the_key', 'value': 'the_value'}]
client.call(posts.NewPost(newPost))
for example on the end of wp-settings.php I add:
class XmlRpcAcf {
public function __construct(){
add_action('save_post', array( $this,'my_save_post'), 12, 3);
}
public function my_save_post( $post_ID, $post, $update ){
//error_log("XmlRpcAcf.save_post($update)[$post_ID]:".json_encode($post), 0);
if (!array_key_exists('_acf_nonce', $_POST)) {
foreach ( (array) has_meta( $post_ID ) as $meta ) {
if (substr($meta["meta_key"], 0, 1) == '_') {
continue;
}
update_field( $meta["meta_key"], $meta["meta_value"], $post_ID );
//error_log("XmlRpcAcf.save_post.meta:".json_encode($meta), 0);
}
}
}
}
$myMXmlRpcAcf = new XmlRpcAcf();