0

I have setup a controller class for my custom post type which extends the WP_REST_Posts_Controller class as I need some additional validation around whether or not the post can be viewed. A custom namespace is also being used.

In terms of REST, all is working well. I can make requests to the endpoint and all the data is returned successfully.

My problem is with the block editor... Anytime I add new, or edit existing, for my custom post type, I simply see a white screen. No errors in the log, nothing. If I remove the custom namespace and use the default, it works fine.

Can't seem to find a similar issue anywhere.

Any ideas?

My register_post_type includes:

'show_in_rest'          => true,
'rest_base'             => 'articles',
'rest_controller_class' => 'KBS_Articles_API'

My class extending WP_REST_Posts_Controller has the following in it's __construct method: class KBS_Articles_API extends WP_REST_Posts_Controller {

/**
 * Get things going
 *
 * @since   1.5
 */
public function __construct( $post_type )   {
    parent::__construct( $post_type );

    $this->namespace = KBS()->api->__get( 'namespace' ) . KBS()->api->__get( 'version' );
} // __construct

The namespace resolves correctly and with the custom namespace, REST calls work perfectly, its just the inability to add/edit posts that is lacking. The post type has support for custom fields and the meta fields are registered.

Any ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.