AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
824 stars 167 forks source link

ACF Blocks incompatible with Underscores.me -themes #199

Open myma-oskari opened 5 years ago

myma-oskari commented 5 years ago

Hi Elliot!

I can't figure out why ACF Blocks won't render on front-end of Underscores-based themes. I checked code and it worked in Automattics Twenty * -themes, but does not render on any Underscores.me -based themes.

I have crossed out any plugin or hosting incompabilities, and only clue is starting theme.

Blocks render correctly on Gutenberg-editor, but in front-end they stay as HTML-comments. Block has only one text-field 'title'. I have also copied example codes on ACF Blocks home page but result is same: backend works fine but frontend won't render.

MY CODE IN FUNCTIONS.PHP

// ACF BLOCK CATEGORY
  add_filter( 'block_categories', 'company_block_category', 10, 2);
  function company_block_category( $categories, $post ) {
    return array_merge(
      array( array(
        'slug' => 'company',
        'title' => __( 'company' )
      ) ),
      $categories
    );
  }

  // ACF BLOCKS
  add_action('acf/init', 'register_acf_blocks');
  function register_acf_blocks() {

    // Read More
    acf_register_block_type( array(
        'name'              => 'read-more',
        'title'             => __('Read More'),
        'description'       => __('Read More -block.'),
        'render_template'   => 'acf/blocks/readmore.php',
        'category'          => 'company',
        'icon'              => 'welcome-add-page',
        'keywords'          => array( 'readmore' ),
    ) );
  }

ACF/BLOCKS/READMORE.PHP:

<div>
  <h2><?php echo get_field('title'); ?></h2>
</div>

PAGE SOURCE CODE ON FRONT END:

<!-- wp:acf/read-more {
    "id": "block_5d179c44ebd42",
    "name": "acf\/read-more",
    "data": {
        "otsikko": "",
        "_otsikko": "field_5d08c12a95e74",
    },
    "align": "",
    "mode": "preview"
} /-->

I can't get any errors anywhere and not a single mention about this anywhere in internet. Could you help me out with this one?

elliotcondon commented 5 years ago

Hi @dm-oskari

I'm not familiar with the Underscores.me theme, but this issue suggests that the theme is unable to render dynamic blocks. I would check with the theme author if the theme is compatible with dynamic blocks such as the "latest post" block in WP.

teresarojas commented 4 years ago

Hi, I am having same issue with my UnderscoresMe based theme. Would you share with me if you found any workaround? Thanks.

myma-oskari commented 4 years ago

Sorry, we wasted few days to figure out it, but we had no luck. Eventually we end up to change back from gutenberg editor to our own flexible fields based content editor. After that we have used our own starter theme developed from Twenty Nineteen and ACF Blocks has worked like a charm.

julian-vidal commented 3 years ago

Hey there!

Was someone able to figure it out? I'm stuck because of that. Thanks!

jubarbie commented 3 years ago

Hey, I'm creating a theme based on Underscodes.me and I'm building a lot of Gutenberg Block and it works well

Tanzeel-Taz commented 2 years ago

@jubarbie how you rendered blocks on front-end with Underscores.me theme?