XML-RPC
-
Hi forum
I want to add/edit/remove custom fields of some post using xmlrpc.php , please can someone show me simple php code .
-
Hi,
You can enable disable XML RPC settings from wordpress admin area -. Settings – writing settings.
– Select checkbox for “XML-RPC” to enable it and save changes.
This settings can be modified by admin authentication users only. Once change the settings error should be resolved.
Also refer this:
http://www.bestwpthemez.com/wordpress/wordpress-error-xml-rpc-services-are-disabled-2853/
Thanks,
Shane G.
Thanks Shane G , but your answer is not for my question , my XML-RPC is already enabled , and I have already used this code and got post’s data
function xmlrpc () { include_once( '../wp-includes/class-IXR.php'); define('BLOG_ID', 0); define('RPC_USERNAME', 'admin'); define('RPC_PASSWORD', '******'); $client = new IXR_Client('http://example.com/xmlrpc.php'); $client->query('metaWeblog.getRecentPosts', BLOG_ID, RPC_USERNAME, RPC_PASSWORD); $data = $client->getResponse();Now I want simple php code to add/edit and remove the custom fields of post
I found this http://lists.automattic.com/pipermail/wp-xmlrpc/2009-April/000324.html
where I found code to add and edit posts by xml-rpc
$post = array( "title" => "Test Me Please", "description" => "Hi there!", "custom_fields" => array( array( "key" => "state", "value" => "Utah" ), array( "key" => "country", "value" => "USA" ) ) ); $rpc = new IXR_Client( 'http://localhost/wp/trunk/xmlrpc.php' ); $status = $rpc->query( "metaWeblog.newPost", 1, $username, $password, $post, false );and
$post_id = 4; $post = array( "title" => "Test Me Please", "description" => "Hi there!", "custom_fields" => array( array( "id" => 3, "key" => "state", "value" => "California" ), ) ); $rpc = new IXR_Client( $rpc_url ); $status = $rpc->query( 'metaWeblog.editPost', $post_id, $username, $password, $post, false );But I can not find way to add custom fields , anyone help me please.
Ok , I found the way , it is possible whit metaWeblog.editPost query , only need set array without id’s of custom fields.
$cf_array = array( "key" => $_POST['key'], "value" => $_POST['value'] ); $post = array( "title" => $_POST['title'], "description" => $_POST['description'], "mt_excerpt" => $_POST['mt_excerpt'], "custom_fields" => $cf_array);Thanks
The topic ‘XML-RPC’ is closed to new replies.