Custom Fields
Re-Envisioned
Support General type="post" / field_type="checkbox_list" returns only single id

  • Creator
    Topic
  • #8937
    flowdee
    Participant

    I setup a field of type “post” and field_type=”checkbox_list” in order to select multiple posts.

    https://pastebin.com/TLKCfN5x

    When saving the post, the backend shows the checked posts correctly.

    But when getting the data on the frontend:

    $tour_ids = rwmb_meta( ‘prefix_fp_tours’ );

    My variable $tour_ids only returns a single id.

    Tried WP’s function:

    $tour_ids = get_post_meta( get_the_ID(), ‘prefix_fp_tours’, false );

    and here I get an array of ids.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #8942
    Anh Tran
    Keymaster

    Hello,

    I’ve just tried your code and see it works. The helper function returns an array of IDs. Maybe you register meta boxes only for the admin (with a check like is_admin())?

    #8944
    flowdee
    Participant

    Mh I’m registering the metaboxes as follows:

    add_filter( ‘rwmb_meta_boxes’, function( $meta_boxes ) { … }

    #8961
    Anh Tran
    Keymaster

    The strange thing is the code works fine to me. Where do you put the add_filter code? Is it under any condition?

    #8962
    flowdee
    Participant

    Nope. It’s directly executed in the functions.php of a theme

    #9013
    Anh Tran
    Keymaster

    Can you send me the site info via contact page? It’s quite strange and I might need to look at the site’s code to debug it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Newsletter

Subscribe to our newsletter to receive news and tutorials for Meta Box and WordPress.


grid gear info copy caret-up caret-down trash