Support

Account

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 🙂