Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created June 19, 2015 20:52
Show Gist options
  • Save joshfeck/599a3d09032a6164c873 to your computer and use it in GitHub Desktop.
Save joshfeck/599a3d09032a6164c873 to your computer and use it in GitHub Desktop.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// first get the template slug
function get_espresso_event_template_slug( $post_id = null ) {
$post = get_post( $post_id );
if ( ! $post || 'espresso_events' != $post->post_type ) {
return false;
}
$template = get_post_meta( $post->ID, '_wp_page_template', true );
if ( ! $template || 'default' == $template ) {
return '';
}
return $template;
}
function add_my_stylesheet() {
// now you can check for a template slug match
if ( get_espresso_event_template_slug() == 'template-CFW-rt-sidebar-no-title.php' ){
wp_enqueue_style( 'stylesheet_name' );
}
}
add_action( 'wp_enqueue_scripts', 'add_my_stylesheet' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment