Hi,
I'm using the awesome GenerateBlocks plugin to create query loops throughout my site, in this case to display a list of events.
My Event CPT is connected to a Provider CPT via a MB relationship.
On my list of events, for each event I would like to display the name of the Provider (post title) connected to it.
I'm not able to control the code of the query directly (GenerateBlocks does it), but here is a code snippet I can use to replace an element from the query into a custom one:
add_filter( 'render_block', function( $block_content, $block ) {
if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'licensee-name' ) !== false ) { // CSS class 'licensee-name' to be added to the block where the value should be output
$myreplace1 = 'placeholder'; // Block content should be set to the word 'placeholder'
$myinsert1 = get_post_meta( get_the_ID(), 'event_host'); // custom field value to retrieve
$block_content = str_replace( $myreplace1, $myinsert1 , $block_content );
}
return $block_content;
}, 10, 2 );
Is it possible to modify this snippet to retrieve the Provider 1) name and 2) featured image connected to that Event?
Thank you