Reputation: 63
I am working on a local WordPress install and I am trying to enqueue some stylesheets like I've done many times before but I've never run into this bug before.
Here is my code in the functions.php file.
function foundation_styles() {
wp_enqueue_style( 'foundation', get_template_directory() . '/css/foundation.css' );
}
add_action( 'wp_enqueue_scripts', 'foundation_styles' );
When viewing page source this is the file path that was enqueued:
<link rel='stylesheet' id='foundation-css' href='http://localhost/FoundationwebsiteC:xampphtdocsFoundationwebsite/wp-content/themes/foundation/css/foundation.css?ver=4.0' >
Instead it should be:
<link rel='stylesheet' id='foundation-css' href='http://localhost/Foundationwebsite/wp-content/themes/foundation/css/foundation.css?ver=4.0' >
Notice the C:xampphtdocsFoundationwebsite/
hidden in the middle of the file path.
The exact same thing happened when I used get_stylesheet_directory()
instead of get_template_directory()
The filepath for my local install is:
C:\xampp\htdocs\Foundationwebsite\wp-content\themes\foundation\css
Anyone know what is causing my filepath to be so funky?
Upvotes: 1
Views: 1283
Reputation: 2157
use this
function foundation_styles() {
wp_enqueue_style( 'foundation', get_bloginfo('template_url') . '/css/foundation.css' );
}
for more information refer this link http://codex.wordpress.org/Function_Reference/wp_enqueue_style
Upvotes: 0
Reputation: 19318
You're using functions that will return a path whereas what you need is a URL.
Replace get_template_directory()
or get_stylesheet_directory()
with get_template_directory_uri()
or get_stylesheet_directory_uri()
.
Example:
function foundation_styles() {
wp_enqueue_style( 'foundation', get_template_directory_uri() . '/css/foundation.css' );
}
Upvotes: 3