Hello,
Full disclosure: I don't know much about API/code, but I'm trying to muddle my way through it with the help of Integromat. I've figured out how to automate the creation of a post that is a metabox custom post type, but now I would like to take that one step further.
I would like to automate the creation of new metabox relationships (one custom post type to another custom post type) via integromat. It doesn't appear that the relationship post type is registered as public, so integromat is unable to create one.
The relationship is called: branch-to-employee
It links the branch post type to the employee post type.
I found this code to add to the child theme functions.php, but how should I modify it to make the branch-to-employee relationship post type show in rest?
/**
* Add REST API support to an already registered post type called 'book'.
*/
add_filter( 'register_post_type_args', 'my_post_type_args', 10, 2 );
function my_post_type_args( $args, $post_type ) {
if ( 'book' === $post_type ) {
$args['show_in_rest'] = true;
// Optionally customize the rest_base or rest_controller_class
$args['rest_base'] = 'books';
$args['rest_controller_class'] = 'WP_REST_Posts_Controller';
}
return $args;
}