Reputation: 391
I know wordpress quite well, but this is the first time that I am creating a child theme. I realized that I need to link everything differently in a child theme.
I got it to work for images by using "stylesheet_directly", like so:
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/icon.png" />
However, I am now trying to enqueue a javascript file in the child theme's functions.php I tried using "stylesheet_directory" again, but it returned a path of the parent's theme, and not the child theme.
Why does "stylesheet_directory" work for the image files in my child theme, but not for enqueing javascript files in my functins file?
Here is what I have in my functions. What else can I use to return the correct path?
wp_enqueue_script( 'ga-slider', bloginfo('stylesheet_directory') . '/js/ga-slider.js');
Upvotes: 0
Views: 1059
Reputation: 404
you can use get_stylesheet_directory_uri()
for relative path to the child theme directory.
get_stylesheet_directory()
will return absolute path of the child theme directory.
Upvotes: 1
Reputation: 740
I have used get_stylesheet_directory_uri()
instead of yours bloginfo('stylesheet_directory')
.
Ex.
wp_enqueue_script('script-name', get_stylesheet_directory_uri() . '/js/script.js', array('jquery'),2, true );
Upvotes: 2