Home Forums Gutenberg acf_register_block_type > enqueue_stuff


acf_register_block_type > enqueue_stuff

    • philby

    • June 6, 2019 at 4:38 pm

    I’m certainly missing something perfectly obvious, but so far I’ve not been able to get ACF to load any CSS or JS files with my blocks.

    I’m defining path constants in a plugin

    if ( !defined( 'WH_PLUGIN_PATH' ) ) {
        define( 'WH_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
    if ( !defined( 'WH_PLUGIN_URI' ) ) {
        define( 'WH_PLUGIN_URI', plugin_dir_url( __FILE__ ) );

    and then include a block’s code
    include( WH_PLUGIN_PATH . 'blocks/agendaselect/agendaselect.php');

    That’s where I actually register the block

    // register the agenda block
        'name'              => 'agendaselect',
        'title'             => __('Agenda'),
        'render_template'   => WH_PLUGIN_PATH . '/blocks/agendaselect/template-agendaselect.php',
        'enqueue_style'     => WH_PLUGIN_URI . 'blocks/agendaselect/agendaselect.css',

    The render template is working without a problem, but no CSS file is ever loaded.
    Echoing the CSS file path in the render template gives the working CSS URI
    echo constant("WH_PLUGIN_URI") . 'blocks/agendaselect/agendaselect.css' –>
    but the CSS is not loaded, neither in the editor nor in the frontend, as far as I can see.

    Did I miss something obvious around how enqueue_style is supposed to work inside acf_register_block_type?

  • I do have exactly the same issues. Any solutions, any suggestions for this?
    (WP 5.2.1, ACF 5.8.0)

    • philby

    • June 14, 2019 at 7:33 pm

    Actually, the solution was embarrassingly simple and obvious: for some reason ACF hadn’t updated from 5.8b4 to the lastest stable version.
    When I noticed yesterday, I updated manually to 5.8.1, and now everything seems to work brilliantly, as is customary with ACF.

  • I updated to 5.8.1, but unfortunatly it didn’t solve the problem.

    • philby

    • June 18, 2019 at 6:41 pm

    Did you try to echo the CSS location in the render template? Does it give a valid URL?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.