• Resolved jeanmaried

    (@jeanmaried)


    I am using WordPress as a headless CMS for a blog with the Custom Post Type UI plugin.

    I have 3 Custom Post Types: Fashion, Travel, Lifestyle.

    Right now I have to make separate fetch requests to each one of these endpoints if I want to get all of the posts.

    Current endpoints:

    
        // gets all lifestyle custom posts
        https://localhost:8888/my-site/wp-json/wp/v2/lifestyle
    
        // gets all fashion custom posts
        https://localhost:8888/my-site/wp-json/wp/v2/fashion
    
        // gets all travel custom posts
        https://localhost:8888/my-site/wp-json/wp/v2/travel

    I need to be able to get all the posts from just one endpoint.

    Is there a way to set up CPT UI so that custom types share a common endpoint?

    Like this:

        // gets ALL custom posts
        https://localhost:8888/my-site/wp-json/wp/v2/all_custom_posts
    • This topic was modified 6 years, 9 months ago by jeanmaried.
    • This topic was modified 6 years, 9 months ago by jeanmaried.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Honestly, I think that’s going to be something that WordPress core would need to make available. We haven’t done anything with the REST API that would do any sort of endpoint setting up, as that’s not something we’ve considered to try to cover with the plugin. Our biggest focus has long been providing a UI that covers collecting arguments for register_post_type() and register_taxonomy() and some things around the management of this collected arguments. The various ways the content is exposed after using those functions has been left to WP core.

    TLDR: I don’t have an answer for how to collect all with one request, unless there’s an API endpoint somewhere that you can use to specify an array of post types.

    Thread Starter jeanmaried

    (@jeanmaried)

    Fair enough. Thank you!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fetch all Custom Post Types posts from single REST endpoint’ is closed to new replies.