Support

Account

Home Forums General Issues Checkbox Field, Commas, Shortcode for get_field? Reply To: Checkbox Field, Commas, Shortcode for get_field?

  • I created the following shortcode for you [acfBr field="FIELD_NAME"]. This will get the field and replace all the commas with <br> tags before it returns the result.

    Paste the following code at the bottom of your functions.php document in your theme folder.

    add_shortcode('acfBr', 'brListFunction');
    public function brListFunction($atts, $content) {
    	extract(shortcode_atts(array("id"=>'','field'=>''),$atts));
    	if($field){
    		if($id=''){
    			global $post;
    			$id=$post->ID;
    		}
    		$content=get_field($field,$id);
    		return str_replace(',','<br>',$content);
    	}
        return '';
    }

    This shortcode was created just for your lists and may not work correctly for all your other fields. If you have any issues please let me know.