Utilize the wordpress conditional tags to selectively enqueue / load your stylesheets. This is best practice so you can call any dependancies as well.
I’ve provided an example of this in practice. Often we only want to include styles for the front page and then style accordingly to your sub page:
<?php
// Is this the front page or home page ?
if (is_front_page() && is_home() ) {
// if so then lets enqueue this!
// for reference the function uses the following parameters:
// wp_enqueue_style( $handle, $src, $deps, $ver, $media ) ?
wp_enqueue_style( 'mystyle', TEMPLATEPATH . 'foo.css', array('my-dependency-styles', 'reset-style'), '1.0.1', 'only screen and print' );
} else {
wp_enqueue_style( 'mystyle', TEMPLATEPATH . 'sub-page.css', array('my-dependency-styles', 'reset-style'), '1.0.1', 'only screen and print' ); ?>
}
Related Posts:
- Remove Open Sans from Twenty Twelve theme
- Enqueue Google Web Fonts Without Messing Up Symbols In URL
- Inbuilt style for jquery-ui-datepicker
- Why is style.css not being enqueued?
- How to conditionally enqueue a stylesheet only for a certain page(s)?
- How to enqueue style before style.css
- What is the correct way to enqueue multiple CSS files?
- Remove wp_add_inline_style
- Is it possible to enqueue a raw CSS string directly from within a template file?
- Use wp_enqueue_scripts, not wp_print_styles?
- Why isn’t my theme processing SASS?
- How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?
- How Can I Use A Child Theme Effectively When Parent’s CSS Is Located in a ‘CSS folder’?
- Disable child theme css on certain pages
- When enqueing a stylesheet, is it possible to remove the type attribute? [duplicate]
- Load custom css after bootstrap
- Enqueue style for Password Reset page
- The correct way to include JavaScript and CSS in my WordPress Themes
- Is it possible to change the path of a css file that is registered through wp_enqueue_style()?
- Relative path instead of absolute for wp_enqueue_script
- get_stylesheet_uri returns wrong path
- Override load-styles.php with admin screen css
- CSS file not registering through add_action
- Relative path in wp_register_style not working
- Custom Admin CSS styles to style media uploader?
- getting url in wp_enqueue_style
- How the Css File is Linked without calling it in header.php?
- Loading different stylesheet on WordPress pages?
- Use wp_add_inline_style to add code to before wp_head?
- why enqueued styles in header.php shows in footer?
- How to insert html/css/javascript code to wordpress plugin
- Adding external stylesheet after ALL other styles
- Different ways to load child theme css
- How to enqueue a random css style?
- How to override Bootstrap css with my child theme css in wordpress?
- Enqueue styles in new site editor in WordPress 5.9
- How to organize priority of plugins CSS files?
- why this media query is not working / not loading when I put it in child theme?
- How do I make header.php use different css for different pages?
- Load CSS in footer, like your can with JS?
- Child theme stylesheet not always overriding “index”
- Child Theme CSS not showing at all
- Faster fonts on mobile
- Display Something in the Header After All Styles are Loaded
- My CSS suddenly doesn’t load anymore [closed]
- How can I force Dynamic CSS via ACF values to update on page load?
- functions.php – inject inline css from file
- Append style tag in head while shortcode runs
- How can I move my custom css to the very bottom of the head section?
- CSS getting injected into index from somewhere after theme/custom CSS is loaded, overriding all of my CSS [closed]
- enqueing Javascript and CSS
- Load custom CSS before admin CSS
- Including CSS files in HEAD based on page content
- How would one set or override a Fallback font for characters in second language?
- First element/selector of enqueued CSS file breaks
- Dequeue styles with query doesn’t work
- Save custom option in CSS file
- How to enqueue stylesheets in child-theme functions.php?
- Dequeing Parent Fontawesome Deques Parent Styles
- Add inline CSS to login page with wp_add_inline_style
- Bootstrap Integtration
- Set different css stylesheet for specific pages [duplicate]
- My Child Theme CSS Isn’t Working
- Font size decreases when child theme is created from parent theme?
- Controling css order
- Why are my parent styles loading after my child styles?
- How to make CSS load live based on options clicked in the theme customizer?
- Replacing parent theme’s IE-specific CSS
- Browser stacks different versions of style.css
- Bootstrap 4 Optimization
- Enqueue MCE Editor CSS in admin page
- plugin not loading my css and js
- Custom theme – Bootstrap CSS not loading via wp_enqueue_style or otherwise
- How enqueue CSS out of theme folder?
- CSS Selector to override default theme.json custom properties in theme stylesheet
- draw diagonal lines in div background with CSS
- Why are my CSS3 media queries not working on mobile devices?
- CSS3 Transition – Fade out effect
- sass :first-child not working
- CSS to select/style first word
- Collapsible button inside a ul list does work in jsfiddle but not in WP
- wordpress in wamp lan doesn’t load css
- JavaScript added as link/stylesheet
- WordPress Twenty Fourteen Theme Sidebar
- Admin pages missing css
- WordPress code editor messed up my code!
- Acessing HTML element with no specific tag on it [closed]
- Order of WP page load (including widgets, php, plugins, media, templates, and CSS) [duplicate]
- How can I add inline CSS for each image?
- Creating a second menu on Twenty Eleven aligned right from the first
- Child Theme not loading multiple stylesheets
- How to display javascript banner in website header?
- Loading css files conditionally useful?
- How to make widgetized footer styles be inherited from body?
- Custom css code in wordpress [closed]
- WordPress site suddenly not showing some DOM elements but mobile is fine
- Editing size of h3 tag in wordpress on a one-off basis
- Content doesn’t fit on large size desktops like 2560×1440
- add custom image to bottom of wordpress default login screen
- How to add a class to a core block in both admin editor and frontend?