REST API – list all posts in a category

  • Unknown's avatar

    Hi.

    I’m trying to learn how to use the REST API.

    I want to get all posts that belong to a category. I don’t know what the ID’s will be as they will be subject to change. Currently, i’m using a slug to reference the category.

    The following will return a category based on a slug, but not the posts .

    /wp-json/wp/v2/categories?slug=myslug

    The following will return all posts in all categories, which is obvs not what i want.

    /wp-json/wp/v2/posts?categories?slug=myslug

    So how do i get all posts in a given category?

  • Hi there,

    What’s the address of the site you’re working on? If it’s not hosted here on WordPress.com, then the best place to seek further help are the WordPress.org support forums:

    https://wordpress.org/support/forums/

  • Unknown's avatar

    Ah right. Sorry i posted on the wrong forum. Please feel free to remove this post.

  • The topic ‘REST API – list all posts in a category’ is closed to new replies.