Skip to content

1.4

Choose a tag to compare

@azeemhassni azeemhassni released this 20 Sep 17:55

What's new

Raskoh now allows to you to add and remove your post types in WP REST API, from this version every post type will be included in WP REST API by default.

API

  1. Methods in Raskoh\PostType::class
    • setRestControllerClass( string $class ) sets rest_controller_class option for the post type
    • setShowInRest( bool $showInRest ) sets show_in_rest option for the post type
    • setRestBase( string $restBase ) sets rest_base option for the post type

Usage

Here is how you can use the above api while registering a post type

$product = new Raskoh\PostType('product');
$product->setShowInRest(true)
    ->setRestControllerClass('WP_REST_Posts_Controller')
    ->setRestBase('products-api')
    ->setIcon('dashicons-cart')
    ->register();

Thanks to @JeyKeu