Reputation: 33
I've uploaded my own design.I just can't get the stylesheet linked correctly. currently my theme resides insides wp-content-themes-(carrental->my theme folder name)-style.css. My index.php page is also in the same folder as style.css.
I'm linking like this:
// for the style.css
<link rel="stylesheet" href="<?php bloginfo('style.css'); ?>" type="text/css" />
// for image in index.php
<img src="<?php bloginfo('carrental'); ?>/assets/acr-logo-1.jpg" width="200" height="100">
What is the correct way of linking please?
Upvotes: 0
Views: 541
Reputation: 197
The best way to include your stylesheet and script files is via wp_enqueue_script() and wp_enqueue_style() inside your functions.php. Take for reference the default activated theme on wordpress (twentyfourteen for example).
Using wp_enqueue_script for example, will ensure that a script file is loaded once, no matter what, so no unpleasant surprises on the way. Take jquery for example, you can add it as a dependency for other scripts.
If you prefer to include in your index.php's header, you can use more options: - ">, another option is to use ...src="echo get_stylesheet_uri()".. or you can use other functions that return your theme path, like others have already written here.
The idea is to output the function return, so get_stylesheet_uri() won't work, because you don't echo it. You use get_stylesheet_uri() when you want to store the value inside a variable.
But the prefered way is still using wp_enqueue_script and wp_enqueue_style functions.
Upvotes: 1
Reputation: 2034
Dont use absolute url.. Use full url. See below code
<link href="<?php echo get_template_directory_uri().'/style.css" />
<img src="<?php echo get_template_directory_uri().'/assets/acr-logo-1.jpg' ?>" />
Upvotes: 0
Reputation: 3156
for style sheet you must use link elemnt of styles
bloginfo('stylesheet_url');
for images you must give the full url of the image like if your images directory inside your theme then in an image source you can give this
bloginfo('stylesheet_directory').'/images/imagname.png'
Upvotes: 0
Reputation: 1192
The below code will return the stylesheet path
bloginfo('stylesheet_url');
so use:
<link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_url'); ?>">
to echo out the stylesheet link!
More information regarding bloginfo can be found here
Upvotes: 0