how do I make a group of radio buttons display each button on a new line?

WordPress AI Code Robot

Create WordPress code snippets for free without a developer!

{Name (First):7.3} requested the  following code from my WordPress AI Code Generator.

how do I make a group of radio buttons display each button on a new line?

The robot generated the following code:

To make a group of radio buttons display each button on a new line in WordPress, you can use the following code snippet:

“`php
function nm_generate_radio_buttons($name, $values) {
$output = '';

foreach ($values as $value => $label) {
$output .= sprintf(
'<label><input type="radio" name="%1$s" value="%2$s"><br>%3$s</label><br/>',
$name,
$value,
$label
);
}
return $output;
}

// usage:
echo nm_generate_radio_buttons('test', array('value1' => 'Label 1', 'value2' => 'Label 2', 'value3' => 'Label 3'));
“`

You can replace 'test' with your radio button group name, and replace the array items with your actual values and labels. Each radio button will be displayed on a new line because of the `<br/>` tag.

More
CODE SNIPPETS