Home › Forums › Gutenberg › Enqueue_style but only once for all blocks › Reply To: Enqueue_style but only once for all blocks
I needed to include a common CSS file for all of my blocks and I was able to do it with this:
function enqueue_foundation_in_admin() {
$current_screen = get_current_screen();
if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {//Check if we're on a Gutenberg Page
wp_enqueue_style( 'foundation', get_template_directory_uri() . '/scripts/foundation-6.5.1.css' );
}
}
add_action( 'admin_enqueue_scripts', 'enqueue_foundation_in_admin' );
Note: this could effect other items in the WordPress admin (text, divs etc.), so be cognizant of that. Otherwise the alternative is using “enqueue_assets” and wp_enqueue_style and just declaring the CSS file for each block.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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.