Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics

ACF – select field, it show only val


I created a custom field that is a select box. I’ve added the column to my admin listing, however it displays the value instead of the option text. For example, if I had <option val=”1″>Option</option> your plugins displays 1 in the column instead of ‘Option’.

Is there a way to get the text to appear? also I’m not sure which type field I should put, array ?


8 years, 11 months ago
Tobias Schutter

Because you wrote custom code to generate the select box, Admin Columsn won’t be able to retrieve the label corresponding to each value. However, you can change the outputted value by using this developer filter: cac-column-meta-value. Here you’ll find a couple of example usages.

Here is a custom example I made to illustrate your case:

function my_column_meta_custom_value( $value, $object_id, $column ) {
	$custom_field_key = 'custom_field_key'; // Enter your custom field key

	if ( 'column-meta' == $column->get_type() && $custom_field_key == $column->get_field() ) {
		if ( '1' == $value ) {
			$value = 'Option';
		else if ( '2' == $value ) {
			$value = 'Anoter option';
		//.. etc
	return $value;
add_filter( 'cac/column/meta/value', 'my_column_meta_custom_value', 10, 3 );
8 years, 11 months ago

You must be logged in to reply to this topic.