Hello,
My website uses AnsPress to create a Q&A forum and uses AnsPress Category extension to create categories inside the forum. My forum has two categories called “depression” & “anxiety”. These categories are listed by executing the following REST endpoints:
https://ninsutu.com/wp-json/taxonomies/question_category/terms/
[
{
"ID": 6,
"name": "Anxiety Disorder",
"slug": "anxiety",
"description": "",
"taxonomy": "question_category",
"parent": null,
"count": 3,
"link": "https://ninsutu.com/questions/category/anxiety/",
"meta": {
"links": {
"collection": "https://ninsutu.com/wp-json/taxonomies/question_category/terms",
"self": "https://ninsutu.com/wp-json/taxonomies/question_category/terms/6"
}
}
},
{
"ID": 7,
"name": "Depression",
"slug": "depression",
"description": "",
"taxonomy": "question_category",
"parent": null,
"count": 4,
"link": "https://ninsutu.com/questions/category/depression/",
"meta": {
"links": {
"collection": "https://ninsutu.com/wp-json/taxonomies/question_category/terms",
"self": "https://ninsutu.com/wp-json/taxonomies/question_category/terms/7"
}
}
}
]
My struggle now is how to retrieve posts listed under “depression” or “anxiety” category. Following WP-REST API documentation, I can filter posts with standard categories using the following endpoints:
https://ninsutu.com/wp-json/posts?filter[category_name]=myStandardCategory
I’m also able to get all posts with the AnsPress’s question and answer using the following endpoints respectively:
https://ninsutu.com/wp-json/posts?type=question
https://ninsutu.com/wp-json/posts?type=answer
What I’m unable to do is filtering all AnsPress posts with a certain custom AnsPress category. I’ve tried the following but it doesn’t work as category_name filter is probably invalid.
https://ninsutu.com/wp-json/posts?type=question&filter[category_name]=depression
https://ninsutu.com/wp-json/posts?type=question&filter[question_category_name]=depression
https://ninsutu.com/wp-json/posts?type=question&filter[cat]=7
I’m stuck with this for several days, please help.
Thanks
Loc