After Upgrading to High Sierra my localhost no longer worked. I followed a number of tutorials and finally got it to work but now my Wordpress sites load but do not load the CSS and Javascript files. When I check inspector it shows that it can not load the files because the directory is wrong. The address bar says localhost/Site-Name but the files are trying to be loaded from localhost/~paul/Site-Name so I must have messed up the configuration somehow.. Hopefully somebody can help. Thanks
Asked
Active
Viewed 1,515 times
2 Answers
0
Try calling your css file in the header.php
like this:
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>[path to your css from project root]/your-css.css">
I had a similar problem and using get_template_directory_uri()
allowed me to solve the it because in that case, the path given in Wordpress gets the files from the root directory.
What happens if you echo
this get_template_directory_uri()
, it's supposed to show you the template dir something like:
localhost/wp-content/themes/[your theme]

DarkCygnus
- 7,420
- 4
- 36
- 59

jwaw
- 1
- 3
-
Mind explaining why? – DarkCygnus Jan 05 '18 at 16:33
-
1@jwaw I'm sorry, I am asking for an Apache configuration solution not a Wordpress solution. – Bwizard Jan 05 '18 at 16:36
-
@DarkCygnus, actually i had a similar problem and using get_template_directory_uri(); allowed me to solve the problem because in that case, the path given in wordpress gets the files from the root directory. what happens if you echo this 'get_template_directory_uri();' that was my main point, it's supposed to show you the template dir something like that : http://localhost/wp-content/themes/[your theme]. Good luck – jwaw Jan 05 '18 at 17:19
-
@jwaw thanks for clarifying. Would you mind including that to your answer? Comments can be deleted without warning and that valuable information can be lost. – DarkCygnus Jan 05 '18 at 17:21
-
@DarkCygnus, thank you for the information. i've included it to my original answer. hope it helps a bit – jwaw Jan 05 '18 at 17:38
-
@jwaw it did :) I suggested some edit to improve its appearance. – DarkCygnus Jan 05 '18 at 17:41
0
I found a workaround which while it does not fix my localhost not showing the Sites folder at localhost/~paul it does allow my Wordpress sites to work. I created a folder within my sites folder called ~paul and then moved all my sites into that. Now the CSS JS etc all load fine and I am happy with that.

Bwizard
- 955
- 2
- 15
- 36