phpwordpresscustom-routes

How to create custom endpoints for custom post types with ACF?


I've created a custom post type with custom fields (using Advanced Custom Fields plugin).
I need to create different routes for each single post, using a code expressed during the creation of the post.
In particular: I have a field called 'post_code', I need to retrieve informations about this particular post using routes like http://my website.com/code=CODE&f=GetInfoPost to acquire informations about that post or http://mywebsite.com/code=CODE&f=GetCategoriesPost to get other field values. This 'post_code' is chosen during the creation of the post. How can I achieve it?


Solution

  • In custom post type for rest api support while you create custom post type you need to add 'show_in_rest' => true. then you have to create your add_rewrite_endpoint for create your routes end point.