I'm following the docs here to query WordPress posts of a custom post type by category. There are answers to this question for PHP, but none that I can find for Python. Unless I am missing something, the function does not work as expected. If I start with the following:
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import GetPosts
from wordpress_xmlrpc.methods import posts
from wordpress_xmlrpc import WordPressTerm
wp = Client('http://www.mywebsite.info/xmlrpc.php', 'myusername', 'mypassword')
Then this successfully returns a list of the categories in question:
categories = wp.call(taxonomies.GetTerms('category'))
This successfully returns a list of (the first 10) posts of the custom post type I'm trying to query:
posts = wp.call(posts.GetPosts({ 'post_type': 'my-custom-post-type' }))
But if I add to that the following:
posts = wp.call(posts.GetPosts({ 'post_type': 'my-custom-post-type', 'terms_names': { 'category' :['my-category',]} }))
It still gives the same result as a query without the 'terms-names' filter, as though the additional term was entirely overlooked. In fact if I add nonexistent categories to the query, it gives the same results without returning an exception/error, such as:
posts = wp.call(posts.GetPosts({ 'post_type': 'my-custom-post-type', 'terms_names': { 'category' :['nonsense-word',]} }))
I've also tried alternate ways such as:
posts = wp.call(posts.GetPosts({ 'post_type': 'my-custom-post-type', 'terms': { 'category' :[72]} }))
... with the same result. What am I not understanding here?
If you read the docs, it doesn't seem to give any complex querying examples. And when I went to the GitHub repo, I see that this was some developer's personal project that's been tested only up to WordPress 3.5 (4.9 is about to come out now) and the last commit seems to be 2 years ago. WordPress is written in PHP. I think the author just didn't go through the trouble of implementing the full features of WP query in Python. And I'd use the WordPress Rest API if possible.
That being said, since it does let you retrieve by post type, you can do the filter yourself if the returned post data contains category info.