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
- Proper way to load styles using a child theme
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- remove empty paragraphs from the_content?
- What is the “with_front” rewrite key?
- Why use if function_exists?
- How to override parent functions in child themes?
- wp_enqueue_script was called incorrectly
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- How long does a deprecated function live in core?
- Solution to render Shortcodes in Admin Editor
- How to add a data attribute to a WordPress menu item
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- remove_action on after_setup_theme not working from child theme
- plugins_url vs plugin_dir_url
- Remove type attribute from script and style tags added by WordPress
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- Upload Multiple Files With media_handle_upload
- How to display custom field in woocommerce orders in admin panel?
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- How do I get the current edit page ID in the admin?
- How to check if a user exists by a given id
- Why isn’t is_page working when I put it in the functions.php file?
- Add tags to the section via functions.php
- Add image size if page template
- How to create a custom order status in woocommerce!
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]
- How to load parent_theme functions.php before child_theme?
- Programatically add options to “add new” custom field dropdown
- Is there any global functions.php file which works for any theme?
- Excluding iPad from wp_is_mobile
- When should you, and when should you not, use wp_list_pluck()?
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- Difference between the_permalink() and get_permalink() function
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Child theme – Overriding ‘require_once’ in functions.php
- Link to user’s profile settings page?
- WordPress Enqueue for homepage only, functions.php, wp-framework
- get php variable from functions php and echo it in theme template files [closed]
- Get menu object from theme_location
- Is it ok to use a function to output the text domain name in a wordpress theme
- Displaying the number of updates available in the Admin area