This doesn't work for me in functions.php:
if( is_page_template( 'template-flat.php' ) ) {
function flatsome_scripts() {
wp_enqueue_style( 'flatsome-style', get_template_directory_uri() .'/flatash/css/foundation.css', array(), '2.1', 'all');
}
add_action( 'wp_enqueue_scripts', 'flatsome_scripts' );
}
However, if I include the style manually in the header of template-flat.php like this it works.
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/flatash/css/foundation.css" type="text/css" />
Why is my functions code not working?
wp_enqueue_scripts?functions.phpexecutes atafter_setup_theme, however conditionals do not function properly untilposts_selection. Thewp_enqueue_scriptsaction occurs after all of the above, meaning code executed here can use conditionals. Long story short, move yourif( is_page_template( 'template-flat.php' ) )conditional inside offlatsome_scripts()