conditional enqueue for single custom post type page template
-
About to go crazy here. I want to call a stylesheet for my project custom post type pages that is unique to that page. For instance, my custom post type is ‘project’ and I am trying to call a specific stylesheet located in my child theme.
Here is my function and implementation in my functions.php file:
// Register and Enqueue Scripts function slay_enqueue_scripts() { wp_register_script( 'slay-responsive-menu', get_stylesheet_directory_uri() . '/lib/js/responsive-menu.js', array( 'jquery' ), '1.0.0', true ); wp_enqueue_script('slay-responsive-menu'); if(get_post_type('project')) { wp_register_style('project-style', get_stylesheet_directory_uri() . '/lib/css/project.css'); wp_enqueue_style('project-style'); } } // Implement enqueued scripts add_action( 'wp_enqueue_scripts', 'slay_enqueue_scripts' );
My scripts load fine, but I can’t get the stylesheet to load into the head of my single-project.php page. Anyone have any ideas?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘conditional enqueue for single custom post type page template’ is closed to new replies.