I have a custom post type that has some data I need to capture at the post level, but I also want to allow users to build with my custom set of ACF Gutenberg blocks. I want them to see ALL user inputs (post fields and blocks) reflected back at them in the Gutenberg editor while editing the post.
I need to be able to render post content (individual fields) from ACF fields that are NOT blocks, but render as sort of a ‘read-only’ block in the Gutenberg editor so they can see how the page will look in its entirety after they save and publish.
I hope my use case makes sense, I could use help architecting this as I’ve been unable to figure it out on my own and after extensive online search. Thanks!
No idea if this helps, but I recently had to get a CPTs ACF metafields displayed in an ACF Block. This is what I put in the blocks template:
$eventdate = get_post_meta( get_the_ID(), 'client_event_date', true );
$eventstarttime = get_post_meta( get_the_ID(), 'client_event_starting_time', true );
$eventendtime = get_post_meta( get_the_ID(), 'client_event_ending_time', true );
$eventtype = get_post_meta( get_the_ID(), 'client_event_type', true );
if( $eventdate ) {
$eventdate = strftime('%A, %d. %B %Y', strtotime($eventdate));
echo '<div class="eventdate"><h4>';
echo $eventdate;
if ( $eventstarttime ) {
$eventstarttime = strftime('%R', strtotime($eventstarttime));
echo ', from ' . $eventstarttime;}
if ( $eventendtime ) {
$eventendtime = strftime('%R', strtotime($eventendtime));
echo ' to ' . $eventendtime; }
echo '</h4></div>';
if ( $eventtype ) {
}
} ?>
Note that this is obviously rendered identically in the editor as on the frontend – which is the reason I’m browsing these forums, trying to find a way to reliably change a Blocks output when in the Block editor 🙂