You can use wp_enqueue_style()
before running get_header()
in your blue.php file.
If you’re looking for a way to do that inside your functions.php file, then the init
hook is a bit too early for is_page_template()
. Try the wp_enqueue_scripts
hook instead:
add_action( 'wp_enqueue_scripts', 'load_my_theme_files' );
function load_my_theme_files() {
if ( is_page_template( 'blue.php' ) ) {
wp_enqueue_style( ... );
}
}
Hope that helps!
Related Posts:
- How to load scripts/styles specific for a page
- TinyMCE custom stylesheets for different post types
- is_front_page not working in functions.php
- Dequeue Scripts and Style for Mobile not working?
- I created a child theme and it doesn’t work for some of the css files
- Child Theme Not Overriding Parent Theme
- Enqueue script o style only if a template part is loaded
- Enqueue styles after a plugin
- How to override enqueued styles using a child theme
- If is multiple page templates
- Register and enqueue style.css custom theme
- Enqueue scripts not working with if is page conditional tag in functions.php
- Enqueue Style Only On Certain Pages Not Working
- Only let plugin add actions to wp_head & wp_footer on single posts
- Remove stylesheets from Campaign Monitor plugin
- enqueue styles for only mobile wp
- different style sheet for just one page template
- Scripts not loading when using the wp_enqueue_scripts action
- Split Media Queries in different files!
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- Parent theme styles overriding child theme CSS [closed]
- I can’t add CSS with functions.php
- Theme JS is available but theme CSS isn’t
- Proper Way to Load stylesheet on Condition
- get_template_directory_uri() links to child theme not parent
- How to pass variables from one function to another or combine functions
- Do we need to change our child function.php to require/include child dir files when we add an over-riding file.php into the child theme
- Page Template Won’t Load Correct CSS File
- Advanced method to control cache of enqueued style/script
- Add custom css file after plugin css with WordPress Child Theme functions.php
- wp enqueue style on about us page
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Test CDN link from function.php or wp_enqueue_script/style?
- CSS style and app.js not loading
- Stylesheet does not load despite functions.php
- How to make the RTL.css the dominant css code?
- How do I create a child theme from PowerMag theme
- How do I dequeue a Stylesheet, stored in an ‘Assets’ folder?
- Child Theme not loading multiple stylesheets
- I need to ‘wp_dequeue_script’ and ‘styles’ and ADD a bunch of other css and js
- Why is style.css not loading through the functions.php
- Javascript and Stylesheet in child page
- custom post with loading script per single post
- Print all inline styles to head
- using enqueue_script in a shortcode isn’t working
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- How to fix enqueue_styles error for a twenty-seventeen childtheme
- wp_head not injecting css
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- Link to user’s profile settings page?
- Shared functions.php across multiple WordPress websites
- How to restrict actions and filters “properly” by conditions
- Extending auth_cookie_expiration based on user role
- AJAX handler throws 400 (Bad request) – why?
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Conditional tag is_page with a custom post type
- Add inline css to theme
- Super simple shortcode not working
- Using “Read More” link with custom excerpt
- what function can I use to automatically output og tags per page/post?
- Add error message on password protected page ONLY when password introduced was incorrect
- Find resources dynamically loading and change or add to the url
- Function wont fire after custom post type is updated
- Removing custom meta data
- Conditional Gravity Forms filter in WordPress Multisite
- When a user logs in, how can they view the website instead of the admin menu?
- Do we have to use ftp to recover from a bad functions.php edit?
- current_time(‘timestamp’) seems to be different from the real current time
- How to get_template_directory() properly on local environment
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Missing argument for the function
- custom functions in function file delete automatically daily
- Init action and refresh page after form action
- Delay a function, any function!
- Fill empty custom field with other custom field
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- How do I find the code executed when wp_head() is called?
- Editor cannot access Theme Options
- Include widget file in functions.php of child theme
- Need help making a short code work
- Is there a function for setting a password to a post?
- WordPress functions.php conditional include another functions file
- reWrite wp-content url to point on my cdn
- sort title descending with title with number
- Add #primary at the end of navlink permalinks on single posts
- Author social media aren’t shown on the page
- get_comments not working properly after WordPress v4.4 update
- Retrieve a custom form field modified by a filter
- What add_action reference should I be using or should I use do_action?
- Allow the access over wp-login.php
- Create input select image URL?
- Including one page with WordPress functions into another
- Dynamically Generating User Meta Field
- Check if there is an post to be published in future
- Unhook the comment form in Buddypress
- Code in functions.php appearing on front-end and dashboard [closed]
- is_preview() always return false
- comment_post function with js not running