Black Friday
Get 35% Off Now!
Black Friday Sale Ends in
Get Admin Columns Now →

Limited: Only the first 100 new customers get 35% off! Discount will be lowered to 25% after that.

Support

Search results for ""

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

ACF – output array

Hi there,

I’m using the ACF add-on of Admin Columns.
I was wondering in there is a way of choosing which key is output when using an ACF field.

Example
When displaying Google Maps value, it outputs the address, lat and lng in the column.
I’d like to display the address only.

How can I achieve that?

Thank you,
Quentin

1 month ago
Stefan
Developer

Hi Quentin,

You can use one of our hooks to alter the value of any column.
The hook you need is ac/column/value and examples can be found here:
https://github.com/codepress/admin-columns-hooks/blob/master/ac-column-value.php
The snippet for the Google Maps columns should look something like this:

function ac_get_maps_address_value( $value, $id, AC\Column $column ) {
	if( $column instanceof ACA\ACF\Column && 'google_map' === $column->get_acf_field_option('type' ) ){
		$raw = $column->get_raw_value( $id );
		$value = $raw ? $raw['address'] : $column->get_empty_char();
	}

	return $value;
}

add_filter( 'ac/column/value', 'ac_get_maps_address_value', 10, 3 );

Let me know if you have any further questions.

1 month ago

You must be logged in to reply to this topic.