Last active
July 5, 2023 17:57
-
-
Save kaelri/fbb51c5919e132043908c835afdda484 to your computer and use it in GitHub Desktop.
wordpress-conditional-block-css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_enqueue_scripts', 'my_block_enqueue_scripts' ); | |
function my_block_enqueue_scripts() { | |
wp_enqueue_style( 'my-normal-css' ); | |
// Do this only if the current post/page has an instance of the related block. | |
if ( has_block('my-block-name') ) { | |
wp_enqueue_style( 'my-block-css' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment