Fields API / Radio Button

Hello Thierry and everybody,

The more I discover Beans, the more I understand how powerful this framework is. Hopefully, I will release my first theme built with Beans Framework by the end of this month. Before that, I have two or three issues/questions.

My question here is related to the way we use the fields API that Beans offers. I have created a little plugin to add a custom post type in my child theme. Here is the complete code. At this line, I use the Beans API to add custom fields to this custom post type.

Unfortunately, the options that I have set here (radio button fields) don't appear in my editor. Here is a screenshot.

What's wrong with my code ? Any advice would be much appreciated. Thanks in advance for your help ! ๐Ÿ™‚


Hey Mathieu,

I am glad to hear your are enjoying it ๐Ÿ™‚

I see in your code (this line) that you set 4 time the same options value and that is why it only appears once. Each radio input needs its own value which is essentially what is needed to define which one is clicked. Below is what your code should look like.

    'id' => 'jobs_field_id_4',
    'label' => 'Field label 4',
    'description' => 'Field description',
    'type' => 'radio',
    'default' => 'value_1',
    'options' => array(
        'value_1' => 'Text 1',
        'value_2' => 'Text 2',
        'value_3' => 'Text 3',
        'value_4' => 'Text 4',

The options array key will be the radio input value and the options array value the label. Note that the default must refer to one of the options key.

I noticed the documentation might have mislead you so I just updated it. Beans Fields API is going to be the main focus area for Beans 1.4.0, we will be improving it with repeatable fields and lot more to look forward to!

Happy coding,

Thanks a lot! It perfectly works. (Repeatable fields! ๐Ÿ˜ฎ Yes! Can't wait !)

Write a reply

Login or register to write a reply, it's free!