Support

Account

Home Forums ACF PRO ACF Blocks: how to apply backend styles different from the frontend ones?

Solved

ACF Blocks: how to apply backend styles different from the frontend ones?

  • Hi, I’m building my first ACF blocks. The acf_register_block_type() lets you add an ‘enqueue_style’ option, but the styles are applied both to frontend and backend, and that’s not what I want.

    I can add only forntend styles simply adding them to my regular style files, without using acf_register_block_type. Good.

    But how can I add only-admin styles? Is there a way?

    Thank you

  • I can answer by myself.

    To load styles only for backend, you can use the enqueue_block_editor_assets action:

    
    add_action('enqueue_block_editor_assets','add_block_editor_assets',10,0);
    function add_block_editor_assets(){
      wp_enqueue_style('block_editor_css', [yourpath] . '/editor-blocks.css');
    }
Viewing 2 posts - 1 through 2 (of 2 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.