WordPress Theme Files Not Linking
In the last couple of days I have been creating a theme for my WordPress site, but suddenly I have experienced problems with it. The php files have stopped linking with the css files.
I have tried creating many different themes and have been getting the same result - a site that only looks like basic html.
Here is the coding I have been using to link them
<link rel="stylesheet" href="styles.css" type="text/css" />
Does anyone have any ideas? Is anybody else having problems with their site?
P.s. Any help will be very much appreciated!! :D
Solutions
You may want to try
/styles.css
, or
./styles.css
. The "." means "up one
directory level
".
However, a better way to do it, would be to link to it like this:
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/styles.css" type="text/css" />
This creates a dynamic absolute path to the stylesheet.
As @rambu said below, wp_enqueue_style is the
proper
way to do this.
function add_my_style() {
wp_enqueue_style( 'my-styles', get_stylesheet_directory_uri().'/style.css' );
}
add_action( 'wp_enqueue_scripts', 'add_my_style' );
Similar questions
Child theme .css files are not overriding their parent .css files
In the last month I have been creating my very first website. Before this I had no coding knowledge so everyhting I learnt was new to me. My problem over the last week is that my child theme .css files (and php. file but that is a different matter) are not overriding their parent .css files. I have been trying to search for a solution all week but ...
Symbolic Links for themes - linking one theme to many wordpress installs
This discussion relateds to plugins: Symbolic Links on dev box with plugins and stylesheets I was wondering if the same problem exists for symlinking a theme to many different wordpress installs. Example structure: domain/footheme/ <- theme resides here The following domains symlinks created here: domain/myfoo.com/wp-content/theme/(footheme) dom...
Linking to a custom .php file in custom Wordpress theme
I'm working on a Wordpress theme that has a Jquery animated contact form in it. I've got the js working (a div that's gets shown/hidden on click, with the form in it). Here's a static HTML/PHP example (click the 'contact' button). What's the problem you say? The problem is that the actual form does not get send. I've got the php file 'contact engin...
Need help linking a button to a function in wordpress theme customizer
I have created a custom control for the theme customizer which is a simple button and label. I am going to be using it as a theme reset button that will clear the theme mod settings to their original state. Now that I have added the control and have it showing up on the customizer, I am not sure where I am supposed to add the code to reset the sett...
Linking a javascript file in wordpress fuctions.php child theme?
Hi I'm trying to several js files in the functions php of my wordpress twenty twelve child theme. Is this correct as it won't load anything? I'm trying to add this snow effect http://seb.ly/demos/JSSnow/snow3d.html http://www.jqueryrain.com/?_ol9H3hd Thanks for your help Any ideas are useful Thanks Judi
Also ask