Custom Fields
Re-Envisioned
Support General Helper function only returning single result from checkbox list

  • Creator
    Topic
  • #21920
    Resolved wgstjf
    Participant

    Hi guys,

    Not sure if I’m overlooking something here but I am only getting a single result when using rwmb_meta to retrieve values for a checkbox list field. You will be able to see from the screenshot that there are two matching the post in question (#768). What am I doing wrong??

    
    $post_services = (!empty(rwmb_meta('post_services'))) ? rwmb_meta('post_services') : '';
    

    Database screenshot

    Thanks in advance,

    Will

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #21923
    Long Nguyen
    Moderator

    Hi,

    Using the helper function for this field always returns an array so you need to loop through it to show the value. Please follow this documentation https://docs.metabox.io/fields/checkbox-list/#template-usage.

    #21926
    wgstjf
    Participant

    Hi Long, not sure if I didn’t explain it properly.

    The issue is that I am NOT getting an array but instead a single value. I am expecting an array containing both values (in this example) but not getting one…

    Any thoughts?

    Will

    #21930
    Long Nguyen
    Moderator

    Hi Will,

    Please share the code that you’ve used to create the checkbox list and get/show the field value. I will make a test on my local site.

    #21939
    wgstjf
    Participant

    Morning Long and thanks for staying with this. Very strange events here…I tried a few debugging options including resorting to default themes, trying different versions of MB and re-coding the function initialising the metaboxes, all with not joy. I then put it all back as it was and suddenly I am getting the desired array returned. I have no idea what happened here…but it is seemingly all working properly now.

    Thanks.

    Will

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