Search code examples
wordpresswordpress-themingwordpress-rest-api

REST API not working in custom post


I have created the custom post in function.php file, it is working fine for me. When I call custom post data via WordPress REST API, It is showing me the error on browser.

Below is the error which was showing me in the browser.

code    "rest_no_route"
message "No route was found matching the URL and request method"
data    
status  404

But rest API is working for default post which is present in WordPress.


Solution

  • For custom post we need to allow the Rest API below is the code

    'show_in_rest' => true,