Home Forums Gutenberg Block displaying another page's block?


Block displaying another page's block?

  • I have a custom block called ‘featured-content-row’.

    I want to pull the content from that block on another page into this page, i/e about page content to home page blocks.

    I’ve setup a block called ‘featured-content-row-pull’ where you can choose a pages ID as well as a title element from the block I’m targeting. This is to ensure it doesn’t show all elements of that pages blocks, just the one i want.

    It runs fine with the following…

    $page_choice = get_field( 'page_choice' ); 
    $page_choice_row_title = get_field( 'page_choice_row_title' ); 
    $post_id = $page_choice ;
    $row_title = $page_choice_row_title;
    $post = get_post($post_id);
    $blocks = parse_blocks($post->post_content);
    foreach($blocks as $block){
    	if( $block['blockName']  == 'acf/featured-content-row' &&  $block['attrs']['data']['site_row_title'] == $row_title ){
    		echo render_block($block);

    However, i get the following notice…

    Notice: Undefined index: id in /local:5757/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php on line 395

    I’m assuming this is because a block is appearing within a block and it doesn’t like the mixing of IDs anything i can do?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.