Skip Navigation

[Resolved] XML-RPC and custom_fields

This thread is resolved. Here is a description of the problem and solution.

Problem:

Update post custom fields with XML-RPC.

Solution:

You can follow WP document to setup the PHP codes, for example:

https://toolset.com/forums/topic/xml-rpc-and-custom_fields/#post-1634117

Relevant Documentation:

https://codex.wordpress.org/XML-RPC_WordPress_API/Posts#Parameters_3

This support ticket is created 4 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by davideE-4 4 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1633825

Hi,
I have created custom fields for some pages and now I would like to manage the creation / updating of data via XML-RCP.
I have already done the same thing with taxonomists and everything works but with the custom fileds I cannot value the data. How should I do it?

This is an example

$content = array (
'post_type' => 'mycustompage',
'post_status' => 'draft',
'post_title' => 'Demo',
'ping_status' => 'closed',
'comment_status' => 'closed',
'custom_fields' => array(
'wpcf-name' => 'Paoul',
'wpcf-surname' => 'Test',
)
);

Thanks

#1634117

Hello,

Please try to change these line from:

'custom_fields' => array(
'wpcf-name' => 'Paoul',
'wpcf-surname' => 'Test',
)

To:

'custom_fields' => array(
	 array( 'key' => 'wpcf-name', 'value' => 'Paoul' ),
	 array( 'key' => 'wpcf-surname', 'value' => 'Test' ),
)

And test again.

More help:
https://codex.wordpress.org/XML-RPC_WordPress_API/Posts#Parameters_3
array custom_fields
struct
string key
string value

#1639581

My issue is resolved now. Thank you!