I am making the transition from a website to another that uses Wordpress.
I created new custom types for my needs (using custom plugin message types), and I created categories for each custom type.
Then I wrote a script in Python (adapted from in this article ) that receives messages from db and removes them remotely on a new (testing) website using the new Wordpress XML-RPC API supported from version 3.4.x.
At the moment, I can post a new message with the correct message type. But if I specify a category, wordpress always returns me this error:
xmlrpclib.Fault: <Fault 401: 'Sorry, one of the given taxonomies is not supported by the post type.'>
I am sure that the message type is supported by this taxonomy. I think I am using the wrong syntax to indicate the category identifier. Here is the code:
import datetime, xmlrpclib, MySQLdb
def post_remotely(post_data):
wp_url = "[my wordpress blog url]"
wp_username = "[myuser]"
wp_password = "[mypasswd]"
wp_blogid = "0"
status = 'publish'
server = xmlrpclib.ServerProxy(wp_url)
data = { 'post_title': post_data['title'], 'post_content': post_data['content'],
'post_date': post_data['data'], 'post_type': post_data['post_type'], 'terms': post_data['categories'],
'post_status': status }
post_id = server.wp.newPost(wp_blogid, wp_username, wp_password, data)
return post_id
And on the caller indicate the category:
new_post['categories'] = [ { 'term_id': 3, 'taxonomy': 'news-cat' } ]
"news-cat" is the name of a taxonomy associated with a custom type of "news". "term-id" is the category identifier that I recognized with phpMyAdmin.
I also tried other approaches, but to no avail. Without a category, it works beautifully.
Thanks in advance for any help :)