0

I am creating WordPress post from my desktop using xmlrpc. Everything else (e.g. title, description, custom_fields) except category is working fine. The category is not assigning to the post.

So far I have tried all this lines -

$content['terms'] = array('post_category' => array( 10 ) ); //Not working
$content['terms'] = array('category' => array( 10 ) ); //Not working
$content['terms'] = array('post_category' => 10 ); //Not working
$content['post_category'] = array('terms' => array( 10 ) ); //Not working
$content['terms'] = array(10); //Not working

$content['categories'] = array(10); //This used to work in olden days but not now

Note: 10 is the category ID which do exist in my website. I have also tried writing the id inside single/double quote marks ie. "10" and '10'

  • If this used to work and no longer does, it sounds like a bug in WordPress core. Have you reported it on trac? – Nathan Johnson Apr 16 '18 at 16:43
  • Did you try these suggestions here? – birgire Apr 16 '18 at 17:17
  • @birgire Yes tried. The lines I have mentioned above contains the same. – Bips Apr 17 '18 at 3:30
  • @NathanJohnson I think wordpress have added new rules from Ver3.4. As per wp documentation, it says (added in 3.4) struct terms: Taxonomy names as keys, array of term IDs as values. codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost – Bips Apr 17 '18 at 3:47
0

I figured out the issue. Actually it is my mistake. I am using XML-RPC metaWeblog.newPost but I was applying solution which is for XML-RPC wp.newPost

So correct solution in case of xml-rpc metaWeblog.newPost is -

$content['categories'] = array('Featured'); //Works.

And in case of xml-rpc wp.newPost, it is -

$content['terms'] = array('category' => array( 10 ) ); //Works

Hope this will help who is newbie like me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.