-
Notifications
You must be signed in to change notification settings - Fork 16
Home
Chris Zarate edited this page Apr 20, 2019
·
1 revision
/**
* Create a MediaItem connection to core/image blocks.
*/
function add_post_connections( $blocks, $post ) {
return array_map( function ( $block ) {
if ( 'core/image' === $block['type'] ) {
if ( isset( $block['attributes_raw']['id'] ) ) {
$block['connections'][] = get_post( $block['attributes_raw']['id'] );
}
}
return $block;
}, $blocks );
}
add_filter( 'graphql_blocks_output', 'add_post_connections', 10, 2 );