Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill custom field when creating a new post #50

Open
veptune opened this issue Nov 12, 2023 · 0 comments
Open

Fill custom field when creating a new post #50

veptune opened this issue Nov 12, 2023 · 0 comments

Comments

@veptune
Copy link

veptune commented Nov 12, 2023

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant