Created
June 19, 2014 18:55
-
-
Save scarstens/a5142c51652516a9a244 to your computer and use it in GitHub Desktop.
Per page CSS and JS loader for wordpress that loads CSS and JS using the URL slug. Loads if it exists, doesn't load if it doesn't exist. Its like get_template_part actions for CSS and JS files! Keywords: this, page, stylesheet, js, javascript, wordpress
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
//load styles and scripts for this page | |
add_action( 'wp_enqueue_scripts', 'this_page_stylesheet' ); | |
add_action( 'wp_enqueue_scripts', 'this_page_js' ); | |
function this_page_stylesheet() { | |
$ss_filename = str_replace('php', 'css', basename(__FILE__)); | |
wp_enqueue_style( 'page-style', get_stylesheet_directory_uri().'/appearance/'.$ss_filename); | |
} | |
function this_page_js() { | |
$ss_filename = str_replace('php', 'js', basename(__FILE__)); | |
wp_enqueue_script('page-js', get_stylesheet_directory_uri().'/js/'.$ss_filename); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment