Hi i need some help with the creation of a custom css file for my page template. There are many topics out there regarding this issue but with each thread i read i get mo
Use the is_page_template()
conditional to selectively load CSS.
In the function below we're hooking into wp_enqueue_scripts
and checking if we're on the custom page template to determine whether to load additional CSS.
If the result is true we'll load a CSS file titled page-template.css
from a css/
folder inside your theme. Update the path to load the correct file.
function wpse_enqueue_page_template_styles() {
if ( is_page_template( 'mytemplate.php' ) ) {
wp_enqueue_style( 'page-template', get_stylesheet_directory_uri() . '/css/page-template.css' );
}
}
add_action( 'wp_enqueue_scripts', 'wpse_enqueue_page_template_styles' );