Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Filter the generated REST routes by filtering the show_in_rest arg in register_post_type function
function dbdb_unset_rest_routes( $args, $post_type ) {
$allowed_post_types = array( 'page', 'post', 'company', 'job' );
$allowed_post_types = apply_filters( 'dbdb_unset_rest_routes_types', $allowed_post_types );
if( in_array( $post_type, $allowed_post_types ) ){
return $args;
} else {
$args['show_in_rest'] = 0;
return $args;
add_filter( 'register_post_type_args', 'dbdb_unset_rest_routes', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment