Tell us what you are trying to do?
Not sure why this wouldn't work for Toolset Custom Post Types (specifically)...
add_filter( 'register_post_type_args', function( $args, $post_type ) {
if ( 'model' === $post_type ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'Model';
$args['graphql_plural_name'] = 'Models';
}
return $args;
}, 10, 2 );
Toolset CPT:
Name plural = Models
Name singular = Model
Slug = model
Is there any documentation that you are following?
We have looked at other posts concerning register_post_type_args and wpcf-post-type but no more clarity.
Is there a similar example that we can see?
A whole package like this shouldn't be necessary in our case, but here's how someone else managed to hook on to the expose rest settings:
hidden link
One concern I have about that is the age of the addon. WPGraphQL is an actively developed plugin.
Here is GraphQL's documentation:
hidden link
Please note that we're not looking for custom programming, but to understand why Toolset wouldn't work with this where others would.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
I'm not aware about hooking those extra arguments to post type for graphSQL.
I would like to know here - is the model post type is created using Toolset?
what if you try to use the later priority for example 30 or more or 99 with your hook.
For example:
add_filter( 'register_post_type_args', function( $args, $post_type ) {
if ( 'model' == $post_type ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'Model';
$args['graphql_plural_name'] = 'Models';
}
return $args;
}, 99, 2 );
BRILLIANT! Hadn't even occurred to me, but yes, the priority was the issue. Thank you!