Custom Fields
Re-Envisioned
Support MB REST API REST API Not showing all custom meta boxes

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #11681

    xanthestudios
    Participant

    Also doesn’t work with following https://www.pdpa.co.uk/wp-json/wp/v2/events.

    #11689

    Anh Tran
    Keymaster

    Hi Peter,

    All fields in all meta boxes are merged and displayed in REST API responses. I see the link https://www.pdpa.co.uk/wp-json/wp/v2/events shows some fields. Can you check that fields come from all meta boxes?

    In case there are some fields are missing, please check your code that registers meta boxes. Make sure there’s no conditions like:

    if ( is_admin() ) { // Or any similar condition
       add_filter( 'rwmb_meta_boxes', 'your_meta_boxes' );
    }
    #11692

    xanthestudios
    Participant

    Hi Anh

    Thanks for getting back to me apologies, the fisr URL I send was another post I was looking at, not the API call back the 2nd API call displays the same results. So yes I can see the following in the data:

    meta_box {
    xs_text_entry_information: "<p>TBC</p>\n"
    xs_checkboxes_hotels: []
    xs_text_hotels: "<p>TBC</p>\n"
    xs_checkboxes_travel: []
    xs_text_travel: "<p>TBC</p>\n"
    xs_tv_checkbox: "0"
    xs_logo_image: []
    xs_website_url: ""
    xs_title: ""
    xs_description: ""
    xs_robots: "noindex, nofollow"
    }
    <code></code>

    But it’s missing two custom meta boxes which I created in the same file as the majority of the above entries. Here is the file where I create the meta boxes, https://gist.github.com/xanthestudios/02b94880b71dd90ecbb28e5aa5ee63a2. YOu can see that most of them are shoiwng in the API results apart from xs_venue_short, xs_venue_long, xs_dates_start_date, xs_dates_end_date and xs_dates_entry_deadline.

    Thank you for your input so far.

    Peter

    #11701

    Anh Tran
    Keymaster

    Hi Peter,

    That’s quite strange. I’ve just tried your code and all fields are showing up to me. Here is my screenshot:

    View post on imgur.com

    Can you check if those fields are not empty? Send me an email with a temporary admin account if you want me to look at the problem closer.

    #11743

    Anh Tran
    Keymaster

    We have found the bug. There are meta boxes sharing the same ID, which makes them overwritten when getting values. In case anyone see the same bug, please change meta box IDs, making sure they’re unique.

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

You must be logged in to reply to this topic.