I am creating a child theme in WordPress. I have uploaded the assets folder that contains css and javascripts. It will be a custom theme.
Inside the tag i have included the the css file to get the css file.
There is a problem in my current code below:
<link href="<?php echo get_stylesheet_directory_uri(); ?>/assets/css/icons/icomoon/styles.css" rel="stylesheet" type="text/css">
The code below will work if it is without the styles.css after icomoon folder.
<link href="<?php echo get_stylesheet_directory_uri(); ?>/assets/css/icons/icomoon" rel="stylesheet" type="text/css">
I want the it to output as: //child_theme_url/assets/css/icons/icomoon/styles.css
I want the styles.css at the end of the include file.
Please help.
I am creating a child theme in WordPress. I have uploaded the assets folder that contains css and javascripts. It will be a custom theme.
Inside the tag i have included the the css file to get the css file.
There is a problem in my current code below:
<link href="<?php echo get_stylesheet_directory_uri(); ?>/assets/css/icons/icomoon/styles.css" rel="stylesheet" type="text/css">
The code below will work if it is without the styles.css after icomoon folder.
<link href="<?php echo get_stylesheet_directory_uri(); ?>/assets/css/icons/icomoon" rel="stylesheet" type="text/css">
I want the it to output as: //child_theme_url/assets/css/icons/icomoon/styles.css
I want the styles.css at the end of the include file.
Please help.
Share Improve this question asked Jul 13, 2016 at 10:27 AdrianAdrian 3,0624 gold badges37 silver badges74 bronze badges 4- Please check http://stackoverflow.com/a/18724137/1719246 – softsdev Commented Jul 13, 2016 at 10:33
- 1 @softsdev Pls flag as a duplicate rather than linking to it – Tim Malone Commented Jul 13, 2016 at 10:37
- 2 Possible duplicate of url of child theme in wordpress – Tim Malone Commented Jul 13, 2016 at 10:37
- checkout this link . i think it will help you codex.wordpress.org/Child_Themes – Naveen Commented Jul 13, 2016 at 10:40
4 Answers
Reset to default 8get_stylesheet_directory_uri()
will return the child theme directory url, you got that bit just right. (get_template_directory_uri()
would return the parent theme directory url.)
Also, if you want styles.css
outputted, the first line of code will do that. Can't see what could be wrong with it. That means something else is likely not working as intended. Are you sure it shouldn't be style.css
, for example? Anyway, such an issue would have nothing to do with WordPress correctly returning the child theme url or not.
Using this hook function in your child theme function.php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'style', get_template_directory_uri() . '/assets/css/icons/icomoon/styles.css' );
}
Note: get_template_directory_uri()
instead of get_stylesheet_directory_uri()
Well,
to put at the end theme-child/style.css, you write the function (in functions.php):
function sp_enqueue_stylesheets() {
wp_register_style( 'style-sp', get_stylesheet_directory_uri() . '/style.css', array(), '1.0', 'all' );
wp_enqueue_style( 'style-sp' );
}
add_action('wp_enqueue_scripts', 'sp_enqueue_stylesheets', 9999 );
Thi is the lastest CSS in the header ;-)
Use following code for child theme directory.
<?php bloginfo('stylesheet_directory'); ?>