You should use WordPress’s built in function wp_enqueue_style
for loading styles.
/**
* Proper way to enqueue scripts and styles
*/
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
https://developer.wordpress.org/reference/functions/wp_enqueue_style/
Related Posts:
- register dependency css and js inside a plugin class
- Hide author from search results meta, still display date and categories
- How to display post meta bellow every posts
- How to locate parent theme functions and add functions to my wordpress child theme?
- How to let mobile navigation menu close when link is clicked?
- how to add functions to my function.php using a child theme?
- Before & After Content – After Content directly below Before Content when using require_once
- Add my footer menu to the header
- Replace header with large image on home page only, using Genesis child theme
- Add a default style if no Featured image is selected
- Add Shortcode to ::before class
- Make a full-width wordpress page
- Site title not showing. Please help me
- Trying to modify content.php
- Fix hover images blink
- Bring Font Awesome icons inside menu A tags
- How to get Post sidebar & footer including html like get_the_content() which only gets content section?
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Styling a specific post after hovering over it
- Hot to edit WooCOmmerce dashboard?
- Using Sprit-sheet on WordPress categories
- Blog Image and Title in Right Sidebar
- Trying to add get_the_title hook to this line
- Add class for the_post_thumbnail_caption()
- custom field – changing an element or background of id div – different versions not working
- dynamically change content of div with php
- Target a specific container to style on WordPress storefront theme
- How to display post_content from database in different on template page?
- How to include different html tags in the header for different pages?
- Displaying POST content with HTML tags and all
- remove blank space where sidebar was
- CSS loading as empty file in Custom Theme
- How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?
- user update profile for custom code
- Display specific main Sub Nav on Woocommerce product pages
- Position a repeated article blocks
- Clone the “proceed to cart” button and place it above checkout on the cart page, but only appear display size is 320px
- Show content by using tags
- How limit the width of a fixed menu-bar on scroll?
- Update same content in multiple posts at once?
- Highlight Single Page Ancestor
- Custom Thumbnails [closed]
- Explode Content within specific HTML element
- Font-Family does not looks like how it should be [closed]
- Custom Theme, Editor won’t wrap text (i.e. change width)
- Where to find the html for WordPress site? [closed]
- Click to expand menu
- Relative post date in recent posts list
- How to add style in functions.php depending on conditions?
- How to remove image on single product and get product to span page?
- Widget edit and add in any page
- widget: input the px value from user and use it as inline style in widget function
- Add end mark at the end of every article
- Create dynamic content from one WP page to multiple other pages
- Modify arguments for parent theme’s `wp_register_style` via child theme
- Styling admin page rows in order of importance (checkboxes)
- Hide button based on PHP result
- Why isn’t my link attribute getting my css?
- How to have Function of a plugin using global vars into a shortcode?
- How to save the output of php variables used in inline css code to the main style.css?
- Editing the contents of just one div on a page from wordpress
- Revision History for Entire WordPress Site
- Show contact 7 form in popup
- wp add inline style in loop
- Child theme not working properly
- WordPress – Image href for home menu nav not working
- How Can I Center the Logo in the Navigation Menu? [closed]
- Overwriting a Shortcode
- featured post as div background
- Combining fancybox with multiple thumbnail plugin
- Display pages from specific page template
- Trying to customize wordpress drop down categories
- Show Nav Link To Users Signed In
- WP_Nav Highlight Parent Issue
- Cant get theme to change footer color through theme customizer
- Changing 2011 theme header image based on user dropdown
- How to change the menu color
- How do I use CSS or PHP to customize WordPress Form Manager Plugin Table?
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- How can I add more code to this?
- Sidebar doesnt get updated?
- Converting Menu Links to List Elements
- PHP Puzzle: Unique Styles with PHP loop
- How to change a specific character in a theme option value – replace a space with a plus sign
- How to NOT override inline css rules
- How to refresh a template page on WordPress in 3 seconds – easiest method?
- How to use plugins_url() inside PHP stylesheet file [duplicate]
- Add CSS class to PHP Statement
- How to get shared CSS body class between translated WPML pages [closed]
- Encode code snippet in AJAX endpoint
- How to add margin underneath woocommerce total price amount -> productpages
- How do I get Roboto Google Font to display normal font-style? [closed]
- Using PHP for background-image property [closed]
- Integrating CSS Into a WP Function Call [closed]
- How to customize posts in WordPress by using HTML and CSS?
- How to create and add js and css file when server is not on my PC?
- WP_Query not returning results
- which php or css file has generated an inline style in WordPress that overwrites my css
- Load slideshow.css file only if Slideshow is checked / on
- Predefine Magazine Style Layouts