• Hi,

    I am using XMl-RPC via PHP and the metaWeblog API to edit existing WP posts. These posts have tags and one custom field.

    Using the editPost API, I can supply tags (“keywords”) to WordPress, but doing this only ADDS those tags to the existing post. I don’t know how to remove any tags already attached to that post that I no longer want. In other words, I’d like to add AND remove tags for a post via XML-RPC.

    On a related note, the custom field. Each post has one custom field, let’s call it “custom1”. This field is created with the initial post and is assigned a value, say “value1”.

    I can’t figure out how to edit “value1” via XML-RPC. Again, I can pass custom field data through the metaWeblog editPost API. But if I pass “custom1” => “value2”, it creates a SECOND custom field with “value2”. Now I have two custom fields. I want to REPLACE the existing custom field (or delete it, and add a new one with the same name and new value).

    Any ideas? Is it possible to edit WP posts with this level of detail via the XML-RPC API?

    thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you provide mt_keywords when calling the metaWeblog.editPost method those are the tags that will be used. If you want to remove a tag from a post simply don’t include it in the list of tags for the post in the mt_keywords field. Think of it as a replace operation.

    Custom fields are little more involved. Call metaWeblog.getPost for a current post that already has custom fields. Each custom field entry will have three fields: id, key and value. The key and value fields correspond to the name and value you entered for the post. The id field is a unique identifier for just that field. When passing that data back to WP via metaWeblog.editPost if you provide and id, key and value fields then an update is done. If you provide just an id with no key or value fields then WP deletes that custom field.

    Here’s the original Trac ticket about this feature:

    http://core.trac.wordpress.org/ticket/5148#comment:4

    and some discussion on the WP XML-RPC email list:

    http://comox.textdrive.com/pipermail/wp-xmlrpc/2007-November/thread.html#103

    http://comox.textdrive.com/pipermail/wp-xmlrpc/2007-November/000103.html

    I just started a new blog (http://weight–loss–diets) and I added a plugin from Unique Article Wizard. Part of this plugin allows you to add your affiliate id and it is assigned as a custom field.

    The problem I am having is that my theme uses the custom field named “key” to add a picture to a scrolling feature on the home page, but when I use the drop down for custom field I don’t see a field named “key”. I only see the two that were installed by the Unique Article Wizard plugin.

    Any thoughts on how I can resolve this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Delete tags and custom fields via XML-RPC’ is closed to new replies.