JavaScript for WordPress Forums The WP REST API – DEMO – Post Arguments

Viewing 1 post (of 1 total)
  • Author
  • #37322

    Hello there,

    This is really two questions into one.

    For the first question, when looking at the “include” argument in the “ – DEMO – Post Arguments”, you say that because we can’t assign an array of values to an argument, we should use “include[]=id1&include[]=id2” for indicating we want to include both posts with id1 and id2.

    But then, when you are looking at the “categories” argument you do use “categories=id1&categories=id2”, which actually doesn’t seem to work as intended as, when I replicated on my own site, it replies with only those posts with “categories=id2”.

    So, if my understanding is correct, without [] the second value overrites the first and, if we want both to be taken into account, we should use [] after the argument name.

    So, here’s the question: Am I understanding it correct?

    As for the second question, and assuming I’ve got the concept above OK, when we use the “categories” argument as this “categories[]=id1&categories[]=id2” we would be getting all posts which have either category with id1 OR category with id2.

    And here’s the second question, is there a way of using endpoint arguments so that we could get only those posts that have both category with id1 AND category with id2?

    Many thanks!

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.