How to correctly create Custom Post Type with custom fields through WP REST API V2

后端 未结 1 407
小鲜肉
小鲜肉 2021-02-10 01:13

How do I correctly create a custom post type record through the wp rest api v2 with custom fields? Unable to create custom fields or update them.

I have installed the su

1条回答
  •  [愿得一人]
    2021-02-10 01:41

    There was a glaringly obvious problem with my wordpress plugin where the add action function name did not match the actual function name register_something_random and slug_register_something_random()

    add_action( 'rest_api_init', 'register_something_random' );
    function slug_register_something_random() {
    

    Should be

    add_action( 'rest_api_init', 'register_something_random' );
    function register_something_random() {
    

    Made this change and all is now ok

    0 讨论(0)
提交回复
热议问题