type="post" / field_type="checkbox_list" returns only single id

Support General type="post" / field_type="checkbox_list" returns only single id

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #8937
    flowdeeflowdee
    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.

    #8942
    Anh TranAnh 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
    flowdeeflowdee
    Participant

    Mh I'm registering the metaboxes as follows:

    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) { ... }

    #8961
    Anh TranAnh 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
    flowdeeflowdee
    Participant

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

    #9013
    Anh TranAnh 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 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.