In the event a child theme is being used, this function will return the child’s theme directory URI. Use get_template_directory_uri() to avoid being overridden by a child theme.
use : get_stylesheet_directory_uri()
Example code Here
<?php
function my_theme_enqueue_styles() {
$parent_style="parent-style"; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
Related Posts:
- Getting rid of unused css directives [closed]
- Change logo on each page of University Hub theme [closed]
- How do I copy my Parent Templates to my Child Templates?
- How to load parent theme style.css?
- Child Style.css not overriding parent theme style located in assets/css/main.css
- How does a Child Theme works?
- Creating new templates in child themes breaks layout
- Port existing Bootstrap site to WordPress?
- What’s the default order used by WordPress to load CSS files?
- The requested theme does not exist. Stylesheet is missing – error after changing style.css name to my-styles.css in wp child theme?
- Why submenu item’s background color is not changing by css?
- Strange Theme Error – parent style occasionally showing though child theme
- Child theme after CSS modification
- Custom Theme Additonal CSS “” are transformed to “>” and “<”
- how to add version of style.css in wordpress
- How to move the sidebar in TwentyFifteen to the right?
- Override parent theme translation on child theme
- How to set thumbnail image for a (child) theme
- How can I version the main CSS file?
- Do Child-Themes automatically load the Translation from the Parent-Theme?
- Difference between stylesheet_directory and template_directory
- How to override the “inc” folder (or any folder) in a theme using child theme?
- I’m trying to add an image in my CSS
- Edit theme wp_head
- The style.css stylesheet doesn’t contain a valid theme header
- Are custom inner theme folders in any way overridable by child themes?
- Override parent theme translation on child theme
- Child-theme breaks site
- Want to create Child theme, but already edited Parent theme css files and some php files
- Can I create multiple instances of the BuddyPress Activity Stream with separate themes? [closed]
- Can’t Install Child Theme “The parent theme is missing. Please install the “Default” parent theme.”
- Can I rename a theme’s folder and still receive updates?
- Child theme not visible
- Overwriting templates in child theme and performance
- how to remove padding from left and right side? [closed]
- 404 Error while accessing the font files
- Should a child theme share the same theme options row as the parent, or should it have it’s own options row?
- Inject widgets from one sidebar into another with PHP
- Where all are child themes recorded when they are created in WordPress
- I have some doubts regarding how to implement child theme
- How do I get rid of or change the footer in my child theme?
- Custom CSS doesn’t work in edit mode
- Remove transparancy in Sydney theme’s headerimage
- How can I add class to every quote element?
- Edited Child Theme’s “header.php” but it doesn’t appear to change the file
- Updating my free theme delete all my changes [closed]
- Do not show one specific widget on one specific page
- How to style the post previews/links without it affecting the main posts?
- Different logo on homepage
- How can we hide the parent’s theme url at the child themes details on a multisite?
- Cannot apply custom css to IE in the theme
- how do i in ignore/disable/delete a javascript call from parent in child theme?
- Is it good practice moving the main stylesheets after the plugin styles?
- What Generated Classes and IDs That Is Always Used On All Themes?
- Passing dynamic options from backend to frontend
- Creating a child-theme: CSS not loading
- simplified explanation on child themes?
- Calling external Libraries in WordPress
- On a Https site, Css and Js Url are back to http after redirect the site
- How can I remove all traces of a theme?
- WordPress activate theme error $pagenow
- Theme update deleted my custom page
- Updating WordPress Theme Files
- Increase content area width in TwentyFourteen [closed]
- Using Grunt and keeping theme comments
- Homepage showing a simple listing of title, featured image, then posted on
- Background image appears on localhost site but not online
- Event Organiser breaks the theme [closed]
- WordPress Theme Breaking on Migration to Live Site [closed]
- how would I change background color of a theme using a plugin?
- WordPress doesn’t recognise created theme
- Menu items do not “open” when mouse hover over them?
- My blog suddenly can’t find my stylesheet?
- WP Nanoplex 1.0.3 malfunction
- removing side space between para and container on generatepress?
- Understanding the child / parent theme relationship
- Remove the breadcrums on a theme W
- How Can I Disable WordPress Theme Self-Update?
- How to customize a section of a widget only on certain pages or page
- How can I fix my theme header for my CSS stylesheet?
- Custom homepage with recent blog posts
- Adding custom html/css/images to Theme
- how make wp include urls as https?
- style.css of my custom theme is not being applied at all
- Why does WordPress Editor Only Use Half the Box?
- CSS in child theme isn’t working properly
- TwentyFourteen Theme : Changing grid layout
- Featured images are cropped on index and post page
- How to allow users to switch to the child theme from front end without plugin?
- EM in CSS different size on wordpress then elsewhere [closed]
- How do I block a subdirectory from WordPress theming?
- Overwrite template-tags.php in child theme
- How to Hide Blog Post Author?
- How can i limit wordpress post title characters in sidebar?
- Commenting in CSS (//) equals “none”? [closed]
- How to change the standard width of a page
- how to add dynamic footer credit in Greatmag theme [closed]
- Theme install failed
- How can i remove footer credit text
- Help with Divi logo not appearing for 10s