Sauter la navigation

[Résolu] Register Post Type Args for WPGraphQL…

This support ticket is created Il y a 1 année et 11 mois. There's a good chance that you are reading advice that it now obsolete.

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)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par shawnW-3 Il y a 1 année et 11 mois.

Assisté par: Minesh.

Auteur
Publications
#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:
lien caché

One concern I have about that is the age of the addon. WPGraphQL is an actively developed plugin.

Here is GraphQL's documentation:
lien caché

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

Les langues: Anglais (English )

Fuseau horaire: 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!