Custom Fields
Re-Envisioned
Support MB REST API MB Term Meta and MB Rest API not working

This topic contains 2 replies, has 2 voices, and was last updated by  Anh Tran 11 months ago.

  • Creator
    Topic
  • #12127
    Resolved
    mp81
    Participant

    Hi,

    I bought the premium extensions solely for the purposes of using the MB Rest Api extension together with the MB Term Meta extension.

    However, from my experience meta fields are not writable to terms via the WP REST API at the moment with the code that is available.

    CASE 1 – WORKING WITH CUSTOM POSTS

    I registered a custom post type called video with the following rest api key properties:

    
    'show_in_rest'          => true,
    'rest_base'             => 'videos',            
    'rest_controller_class' => 'WP_REST_Posts_Controller',            
    

    I then associated a meta box field of type text with id video_id with this custom post type

    array(
        'id' => 'video_id',
        'name' => esc_html__( 'Video ID', 'digg-core' ),
        'type' => 'text',
    )
    

    After doing this, I was able to submit a POST request via REST API to /wp-json/wp/v2/videos

    My parameters were:

    
    "title": "A test video",
    "meta_box": "{
        "video_id": "12345"
    }"
    

    The POST request was successfull and the meta box field video_id was successfull set the value “12345”

    CASE 2 – NOT WORKING WITH CUSTOM TAXONOMY

    I then proceeded to register a new custom taxonomy called video tag with the following key rest api properties:

    
    'show_in_rest'          => true,
    'rest_base'             => 'video-tags',            
    'rest_controller_class' => 'WP_REST_Terms_Controller',            
    

    I then associated a meta box field of type text with id video_id with this custom taxonomy

    array(
        'id' => 'video_id',
        'name' => esc_html__( 'Video ID', 'digg-core' ),
        'type' => 'text',
    )
    

    A POST request to /wp-json/wp/v2/video-tags with the same parameters did not work:

    
    "title": "A test video",
    "meta_box": "{
        "video_id": "12345"
    }"
    

    It the meta box field video_id of the taxonomy video-tag that was created did not have a value.

    Can you please provide a working example of creating a taxonomy term via REST API and actually associating a meta_box field with it.

    Thanks,

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.