You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was having trouble adding a meta field for a custom post type. After some debugging, I found that the plugin is being loaded before the custom post types are.
So even though you register your meta field through the register_meta function, it won't get added because the post type hasn't been added yet.
Solution
Moving the plugin to load on do_graphql_request instead of graphql_init seems to do the trick. I'm unaware of any side effects by doing this, if there are any.
I would sugget to either move the plugin to load on do_graphql_request. If this is not a good solution please let me know and I'll prepare a PR for wp-graphql with solution for a second hook that fires on init.
Regards,
Rasmus
The text was updated successfully, but these errors were encountered:
Hi,
Firstly, great little plugin.
I was having trouble adding a meta field for a custom post type. After some debugging, I found that the plugin is being loaded before the custom post types are.
Issue
The plugin instantiates on graphql_init, which I think is the locigal place to hook in. However, wp-graphql instantiates on after_setup_theme, which is before custom post types are added on the init hook.
https://codex.wordpress.org/Plugin_API/Action_Reference
So even though you register your meta field through the
register_meta
function, it won't get added because the post type hasn't been added yet.Solution
Moving the plugin to load on
do_graphql_request
instead ofgraphql_init
seems to do the trick. I'm unaware of any side effects by doing this, if there are any.I would sugget to either move the plugin to load on
do_graphql_request
. If this is not a good solution please let me know and I'll prepare a PR for wp-graphql with solution for a second hook that fires oninit
.Regards,
Rasmus
The text was updated successfully, but these errors were encountered: