WordPress Custom Post Type Missing from the REST API? Check These Settings

A custom post type can appear in the WordPress dashboard yet return rest_no_route when an app requests it. That usually means the API route was never registered, the route name differs from the one the developer guessed, or a permission rule blocks the request. Check those separately before adding another REST plugin or changing a security rule.

Editorial illustration: a developer traces a WordPress custom content type from plugin registration to its REST API route and permission check

Editorial illustration; the route and permission steps are conceptual, not a screenshot of WordPress.

Summary

  • A custom post type must opt into the REST API with show_in_rest when it is registered.
  • The endpoint uses its REST base, which can differ from the post type key, and a private item still requires permission.
  • Test the route, registration and authorization separately before changing permalinks or disabling a plugin.

Find the route name first

WordPress exposes core REST routes under the wp/v2 namespace. If a custom type is registered with the key book, its default route is typically /wp-json/wp/v2/book. If the registration sets rest_base to books, the route becomes /wp-json/wp/v2/books. The post type key identifies the type in code; rest_base controls the URL. Do not assume a pretty front-end archive slug is also the REST base.

Start with the REST API index at https://example.com/wp-json/ and inspect the routes listed there. Replace example.com with the site’s actual canonical domain. If pretty permalinks are disabled or the server does not route the path, WordPress documents a query-string form such as https://example.com/?rest_route=/wp/v2/books. The route index helps distinguish a spelling error from a route that was never registered.

Register a public content type for the API

For a custom post type that your own plugin controls, set show_in_rest in the arguments passed to register_post_type:

add_action( 'init', 'site_register_book_type' );

function site_register_book_type() {
    register_post_type( 'book', array(
        'label'        => 'Books',
        'public'       => true,
        'show_in_rest' => true,
        'rest_base'    => 'books',
        'supports'     => array( 'title', 'editor', 'excerpt', 'thumbnail' ),
    ) );
}

Place content-type registration in a plugin or must-use plugin when the content should survive a theme change. WordPress says post types should be registered on the init action. Registering too early can leave the type unavailable when other parts of WordPress assemble routes. show_in_rest also enables the block editor’s REST-based interaction for that type.

After deploying the code, request GET /wp-json/wp/v2/books. A successful public endpoint generally returns a JSON array, even if it is empty. If you set a custom namespace or controller, check those values too; a custom controller can place routes somewhere other than the default namespace.

Diagnose the response rather than guessing

  1. Check whether the route exists. Open /wp-json/ and search for the collection route. If it is absent, verify the code runs, the plugin is active and show_in_rest is true.
  2. Compare key and route base. Read the register_post_type arguments for rest_base and, if present, rest_namespace. Test that exact path rather than the archive URL.
  3. Check the HTTP response. A rest_no_route response suggests the requested method or path is not registered. A 401 or 403 points toward authentication or access checks. A 200 with an empty array means the route exists but no items match the request and current visibility rules.
  4. Test one known published item. Confirm that it is published, belongs to the intended type, and is not excluded by a custom query or access plugin. Use a private browser window for a public read test; use an authenticated client only for content that should require a login.
  5. Check server and security layers. If the route appears in the index but requests fail, review the web server, CDN, firewall and security plugin logs for blocked /wp-json/ requests. Avoid turning off the REST API globally; block only the specific exposure you can justify.

Saving the Permalinks screen can refresh rewrite rules after an archive rewrite change, but it does not fix a missing REST registration argument. Use it only if the route depends on rewritten URLs and the route is otherwise registered. For sites where pretty permalinks fail entirely, inspect server rewrite configuration with the host.

If another plugin owns the post type

Do not edit a vendor plugin just to add one argument; an update may erase the change. WordPress provides the register_post_type_args filter for changing arguments when a type is registered. A targeted example is:

add_filter( 'register_post_type_args', 'site_expose_book_type', 10, 2 );

function site_expose_book_type( $args, $post_type ) {
    if ( 'book' === $post_type ) {
        $args['show_in_rest'] = true;
        $args['rest_base'] = 'books';
    }

    return $args;
}

Test this on staging and check the priority and registration timing if the type still does not appear. The filter only helps if it runs when that post type registers. If a plugin uses its own controller, inspect its documentation instead of forcing WP_REST_Posts_Controller over it.

Custom taxonomies need their own show_in_rest setting. If a taxonomy is attached to the type but missing from the editor or API, verify its registration separately. Custom fields also need explicit REST registration; exposing a post type does not automatically make every post_meta value readable or writable.

Protect data and write operations

show_in_rest makes a route available; it does not mean every visitor can edit every post. Public published content may be readable anonymously, while drafts and write requests require authentication and the appropriate capability. For integration accounts, use a dedicated WordPress user with only the capabilities the integration needs and an application password over HTTPS. Do not paste credentials into browser code or a public repository.

Treat every custom field as a deliberate data decision. Register only fields intended for the API, set a schema and sanitization behavior, and verify the authorization callback for updates. A private note, customer detail or internal workflow value should not become public just because it is convenient for a client application.

Common mistakes

  • Guessing the REST URL from the front-end archive slug.
  • Setting show_in_rest on the type but not the related taxonomy or custom fields.
  • Treating every 403 as a missing route or every 404 as a rewrite problem.
  • Editing a third-party plugin directly instead of using a supported hook.
  • Enabling broad anonymous access to make an integration test pass.

If your integration authenticates as a WordPress user, review application passwords and their limits. For front-end asset issues after a theme or plugin deployment, choose a safe script loading strategy before changing multiple optimizations at once.

My Take

A route that is missing and a route that denies access are different bugs. I’d inspect the route index and HTTP status first, then change one registration or permission setting on staging. That keeps a debugging session from turning into an accidental public-data change.

Bottom Line

Confirm show_in_rest, inspect the actual REST base and namespace, and interpret the response code before editing rewrites. Keep read visibility, write capabilities and custom-field exposure as separate decisions.

Sources