Accessing fields from an ACF options page

Hello, I am successfully accessing ACF data saved in post meta using the meta key. I have just come across a scenario where I would like to access some fields saved to an ACF options page (see ACF | Options Page) which are stored in the wp_options table. Is it possible to expose these fields to GB? The only two sources available are the current post or a specified post.


That’s not possible for now but this feature is in the backlog. :slight_smile:

For now, you can use the PHP filter to have the values displayed in the frontend:

add_filter( 'generateblocks_dynamic_content_post_meta', function( $value, $id, $attributes ) {
	// Change this if you want to use another prefix marker in the editor.
	$prefix_key = 'option_';

	if ( isset( $attributes['metaFieldName'] ) && str_contains( $attributes['metaFieldName'], $prefix_key ) ) {
		$option_key = trim( $attributes['metaFieldName'], $prefix_key );
		$value = get_field( $option_key, 'option' );

	return $value;
}, 10, 3 );

In the editor you just need to add the field, where my_field is your option field:

Just keep in mind that this will not have a live preview in the editor and also, if your field returns an object/array you will have to do more tweaking in the function to work properly. This example should work with most single-value fields, and you can re-use it multiple times, just need that prefix key.

1 Like