Home › Forums › Front-end Issues › Checkbox Shortcode Display as List › Reply To: Checkbox Shortcode Display as List
Hi @flyingeagle,
ACF does not offer any way of overriding this so the best solution would be to create your own custom shortcode to display the value as an unordered list. Copy the following code to your functions.php file:
<?php
function custom_acf_shortcode( $atts ) {
// extract attributs
extract( shortcode_atts( array(
'field' => '',
'post_id' => false,
'format_value' => true
), $atts ) );
$value = get_field( $field, $post_id, $format_value );
if( is_array($value) )
{
$ul = '<ul>';
foreach($value as $val) {
$ul .= '<li>' .$val. '</li>';
}
$ul .= '</ul>';
$value = $ul;
}
return $value;
}
add_shortcode( 'custom_acf', 'custom_acf_shortcode' );
Then use it as follows: [custom_acf field="field_name" post_id="123"]
Hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.