wordpress-xmlrpc-client icon indicating copy to clipboard operation
wordpress-xmlrpc-client copied to clipboard

Fill custom field when creating a new post

Open veptune opened this issue 1 year ago • 0 comments

Hello,

I have rewrite the newPost function to add a custom field, but it doesn't work. Any idea? Thanks

function newPost($title, $body, array $content = array()) { $default = array( 'post_type' => 'post', 'post_status' => 'publish', 'mykey' => 'myvalue', ); $content = array_merge($default, $content); $content['post_title'] = $title; $content['post_content'] = $body;

    $content['custom_fields'] = array(
        'mykey' => 'myvalue',
    );

    $params = array(1, $this->_username, $this->_password, $content);

    return $this->_sendRequest('wp.newPost', $params);
}

veptune avatar Nov 12 '23 12:11 veptune