AdvancedCustomFields / AdvancedCustomFields/acf

ACF Blocks incompatible with Underscores.me -themes

Open
#199 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ACF block registration in functions.php and the template at acf/blocks/readmore.php, then compare the saved block markup in the page source with the block's configured field name. Reproduce the frontend behavior using an Underscores-based theme and check whether the block template is reached; done means the block renders its title on the frontend.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.