Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello igiaki! Please, check your meta info every time you check a category name.

    Your category ID 55 is “artisti” and the meta you need to check is either “artisti” or 54 (again, check your meta info).

    The endpoint you are looking for is this one:

    vision-club.it/wp-json/posts?filter[category_name]=artisti&filter[post_per_page]=10&page=1

    Hope that helps ??

    PS: add “https://www.” normally, wp forum remove the [] brackets if you add the first part of the url.

    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get posts by category, but the array is empty’ is closed to new replies.