ACF in the Template Editor

This feature is only available in WP Ultimate Post Grid Premium

If you’re using the Advanced Custom Fields plugin (or ACF) you can add them to the Template Editor by using the “Custom Field” block.

For any field that’s not just a text field you will have to use some custom code as well to output the part of the ACF you want. This example should help you get started:

function wpupg_acf( $output, $post, $block ) {
	if ( 'acf_field' === $block->key ) {
		$acf_field = get_field( $block->key, $post->ID );
		$output = $acf_field['lat']; // Use any part of the ACF field you need
	}
	return $output;
}
add_filter( 'wpupg_output_grid_block_custom-field', 'wpupg_acf', 10, 3 );

Make sure to change “acf_field” to the actual key of your field and alter the $output variable in any way you want. This code can be added to your theme’s functions.php file.