Reputation: 158
I'm having an issue where I have a local Wordpress install on my Ubuntu machine using XAMPP and I'm trying to work on a theme from scratch. The problem is that any path in index.php that's supposed to refer to other files in the same folder (e.g. <link rel="stylesheet type="text/css" href="style.css">
) is supposed to point to the CSS file in the same folder (/opt/LAMPP/htdocs/blog/wp-content/themes/mytheme
).
Instead the file doesn't load and my browser reveals that it's not found. It turns out my browser is looking way up in the /blog
folder. So for my page to load properly, I have to move everything there, or have the paths descend.
This is incredibly annoying because I have my XAMPP server set up with the same hierarchy as my site is going to have, and I don't want to have to hand-edit all my paths just so that it works like it should on my main website. Does anyone know how I can fix this so that XAMPP/Wordpress will look to load the theme from the /mytheme
folder?
Upvotes: 0
Views: 1621
Reputation: 9041
I always use the following line when i want to reference something in the themes directory:
<?php echo get_bloginfo('template_directory') ?>
For example if i want to load a style sheet contained in mytheme/css i do the following:
<link rel="stylesheet" type="text/css" href="<?php echo get_bloginfo('template_directory') ?>/css/stylesheet.css">
Hope this helps.
Upvotes: 1