Reputation: 427
I have having an issue with the following code :
<!--CSS files -->
<?php
function my_styles_method() {
// Register the style like this for a theme:
wp_register_style('my-custom-style', get_template_directory_uri() . '/includes/front-page.css');
// enqueue the stule
wp_enqueue_style('my-custom-style');
// Register the style like this for a theme:
if (is_page_template('our-story.php')) {
wp_register_style('my-custom-style', get_template_directory_uri() . '/includes/main.css');
// enqueue the stule
wp_enqueue_style('my-custom-style');
}
}
add_action('wp_enqueue_scripts', 'my_styles_method');
?>
I am using the page template our-story.php and using the function as specified here :http://codex.wordpress.org/Conditional_Tags but somehow the main.css file doesn't get loaded. When I comment out the code for the front-page.css file and remove conditional statements than main.css files loaded and works correctly but not within this condition. I am not sure if I am using it correctly.
Looking forward to your response.
Upvotes: 0
Views: 232
Reputation: 8233
Why don't you use the body classes ? http://codex.wordpress.org/Function_Reference/body_class
You can target whatever page / template you want with those classes. Ex:
<body <?php body_class(); ?>>
On the homepage will give you :
<body class="home page page-id-14 page-template page-template-home-php ">
So, if you want specific CSS for homepage :
.home { Your styles }
Upvotes: 4