Do not use “about” as handle
as it seems to be not unique and used by WordPress itself. I don’t see the list of style handles is documented somewhere. Anyway, use something unique like ‘rejaur-about’:
<?php
function load_page_styles() {
if ( is_front_page() ) {
// enqueue front page styles
} elseif ( is_page('about') ) {
wp_enqueue_style(
'rejaur-about', // the problem was the handle
get_template_directory_uri() . '/css/about.css',
array(),
1,
'all'
);
}
}
add_action( 'wp_enqueue_scripts', 'load_page_styles' );
In this particular setting the styles don’t need to be registered before enqueuing them.
Off-topic: be careful with else if
and elseif
.
Related Posts:
- How to load scripts/styles specific for a page
- Dequeue Scripts and Style for Mobile not working?
- Enqueue script o style only if a template part is loaded
- If is multiple page templates
- Enqueue scripts not working with if is page conditional tag in functions.php
- Only let plugin add actions to wp_head & wp_footer on single posts
- enqueue styles for only mobile wp
- Scripts not loading when using the wp_enqueue_scripts action
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- Theme JS is available but theme CSS isn’t
- Advanced method to control cache of enqueued style/script
- Add custom css file after plugin css with WordPress Child Theme functions.php
- Test CDN link from function.php or wp_enqueue_script/style?
- How do I dequeue a Stylesheet, stored in an ‘Assets’ folder?
- 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
- custom post with loading script per single post
- using enqueue_script in a shortcode isn’t working
- WordPress Enqueue for homepage only, functions.php, wp-framework
- deregister scripts on certain page
- Enqueue Script with data attributes
- How to enqueue every script in a folder automatically?
- TinyMCE custom stylesheets for different post types
- is_front_page not working in functions.php
- wp_register_script not loading as expected
- Enqueue less file not working in child theme?
- I created a child theme and it doesn’t work for some of the css files
- Enqueuing External Javascript functions.php
- How to enqueue JavaScript for specific WordPress pages only?
- Enqueue styles after a plugin
- Enqueuing Script in functions.php vs on the page
- wp_enqueue_script add integrity parameter
- Passing arguments to my function with do_action and add_action is not working
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- Load JS Script only for custom post types
- Register and enqueue style.css custom theme
- wp_is_mobile dequeue not working
- Register vendor JS/CSS only on pages that require them?
- Why won’t my scripts load?
- Enqueue Style Only On Certain Pages Not Working
- functions.php How to add css/js depending on Template Name?
- Not sure if enqueuing js scripts properly
- Register and load scripts
- how to en-queue jQuery to load before the tag
- Attempt to change jQuery version caused White Screen of Death
- jQuery does not work
- enqueue_script with filemtime javascript not working
- different style sheet for just one page template
- add_action wp_enqueue_script priority level only works for admins
- linking stylesheets and scripts with functions.php
- Some questions about how proper add 2 CSS file in a WordPress theme?
- In jquery use php variable to execute an enqueued jquery file
- Enqueue script on every page except one
- Run a jquery script on on a certain template page
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- Load JS file only in specific template
- Parent theme styles overriding child theme CSS [closed]
- I can’t add CSS with functions.php
- 404 when enqueue_script using plugin_url
- How to load jQuery in TOP of wp_footer?
- get_template_directory_uri() links to child theme not parent
- 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
- video.js not enqueueing?
- Include Jquery libraries in wordpress theme?
- Page Template Won’t Load Correct CSS File
- Call two different function.js depending on page
- Enqueueing a code block from an options framework
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Why is this function crashing my wordpress installation? [closed]
- colorbox not loading in
- Fatal error: allowed memory size when after using enqueue_script
- wp_enqueue_script() not working
- How to use wp_enqueue_script properly?
- Get webpack to work on child theme
- How to load a css file depending on the current role
- localize_script but data changes dependent on product ID
- WordPress wp_dequeue_script remove all other scripts
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Stylesheet does not load despite functions.php
- How to make the RTL.css the dominant css code?
- Unable to declare AOS library in functions
- How do I create a child theme from PowerMag theme
- WP Enqueue Script Error
- True parameter but jquery register in header and not in the footer with wp_register_script
- Javascript and Stylesheet in child page
- WordPress Jquery+scripts enqueue issue
- Different body image backgrounds on different pages, posts and categories
- wp_enqueue_script only works outside of action
- Exclude javascript in certain page url and all following url’s after forward slash
- Using array page name together with page id to deregister script
- wp_enqueue_scripts called twice?
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- Remove snippets of JS from core
- Why my wp_enqueue_script doesnt work on some page?
- How to fix enqueue_styles error for a twenty-seventeen childtheme
- wp_head not injecting css
- WordPress – Notice: Function wp_enqueue_script was called incorrectly
- dynamically import array from another js file in WordPress
- Loading newest dependency javascript module file in functions.php