Title: XML-RPC
Last modified: August 19, 2016

---

# XML-RPC

 *  Resolved [victordever](https://wordpress.org/support/users/victordever/)
 * (@victordever)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/xml-rpc-1/)
 * Hi forum
    I want to add/edit/remove custom fields of some post using xmlrpc.php,
   please can someone show me simple php code .

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [shane-g](https://wordpress.org/support/users/shane-g/)
 * (@shane-g)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/xml-rpc-1/#post-1247170)
 * 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/](http://www.bestwpthemez.com/wordpress/wordpress-error-xml-rpc-services-are-disabled-2853/)
 * Thanks,
 * Shane G.
 *  Thread Starter [victordever](https://wordpress.org/support/users/victordever/)
 * (@victordever)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/xml-rpc-1/#post-1247176)
 * 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
 *  Thread Starter [victordever](https://wordpress.org/support/users/victordever/)
 * (@victordever)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/xml-rpc-1/#post-1247227)
 * I found this [http://lists.automattic.com/pipermail/wp-xmlrpc/2009-April/000324.html](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.
 *  Thread Starter [victordever](https://wordpress.org/support/users/victordever/)
 * (@victordever)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/xml-rpc-1/#post-1247234)
 * 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

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘XML-RPC’ is closed to new replies.

## Tags

 * [XML-RPC](https://wordpress.org/support/topic-tag/xml-rpc/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [victordever](https://wordpress.org/support/users/victordever/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/xml-rpc-1/#post-1247234)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
