Skip Navigation

[Resolved] Register Post Type Args for WPGraphQL…

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by shawnW-3 1 year, 10 months ago.

Assisted by: Minesh.

Author
Posts
#2551319

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.

#2551767

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 );
#2551805

BRILLIANT! Hadn't even occurred to me, but yes, the priority was the issue. Thank you!