Support » Plugins » Search post by categories WordPress WP-API

  • I wanna search posts by categories in the WP-API. I know I can search posts by the atribute caretories or filter[cat]. But the posts contains more than one categories.

    I tried to search in that way

    {host}/wp-json/wp/v2/posts?categories=69&filter[cat]=[228,246,237]&per_page=50

    or

    {host}/wp-json/wp/v2/posts?categories=69&filter[cat]=228&filter[cat]=246&filter[cat]=237&per_page=50

    or

    {host}/wp-json/wp/v2/posts?categories=69&categories=246&categories=237&categories=228

    This not work for me, these make the search for the last atribute.

    Any idea?

    This is the structure of Json response

    {
        "id": 9333,
        "date": "2016-08-02T14:17:01",
        "date_gmt": "2016-08-02T12:17:01",
        "guid": {
          "rendered": "{post}/?p=9333"
        },
        "modified": "2016-08-03T08:50:35",
        "modified_gmt": "2016-08-03T06:50:35",
        "slug": "{post}",
        "type": "post",
        "link": "{host}/{post}/",
        "title": {
          "rendered": "{post}"
        },
        "content": {
          "rendered": "{post}"
        },
        "excerpt": {
          "rendered": "{post}"
        },
        "author": 3,
        "featured_media": 0,
        "comment_status": "closed",
        "ping_status": "closed",
        "sticky": false,
        "format": "standard",
        "categories": [
          228,
          237,
          207,
          217,
          246,
          231,
          69,
          221,
          270,
          244
        ],
        "tags": [],
        "_links": []
      }
  • The topic ‘Search post by categories WordPress WP-API’ is closed to new replies.