Last active
April 23, 2020 16:06
-
-
Save addisonhall/e556671f1933e692096695314d27d581 to your computer and use it in GitHub Desktop.
Wordpress: Enqueue CSS for custom post type only
This file contains 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 | |
/** | |
* Enqueue specific CSS styles or javascript for a custom post type (cpt). | |
*/ | |
add_action( 'wp_enqueue_scripts', 'my_cpt_scripts' ); | |
function my_cpt_scripts() { | |
if ( is_singular( 'custom_post_type_name' ) || is_post_type_archive( 'custom_post_type_name' ) ) { | |
wp_enqueue_style( 'cpt-style', get_stylesheet_directory_uri() . '/css/your-cpt-style.css', false, '', 'all'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment