简体   繁体   中英

My wordpress theme css files are not working

I've been having some issues with my wordpress theme, i recently created a new theme and tried using it in my wordpress site, but i discovered that the css isn't loading. The css loads properly in my localhost and i didn't make any changes before uploading to the server,but after i uploaded it to the server, my css stopped working. I've never experienced this before and I'm 100% sure my header.php and functions.php file are correct. I checked with chrome dev tools to see if my css is loading, and it loads correctly.

chrome 开发工具

I can see my css files showing in the head section in chrome dev tools, but my website page isn't displaying with the styles. Please what do I do? Also, i used wordpress 5.4.2 in my online server, but i used wordpress 5.3.4 in my local machine, does this affect anything

Looking at your website, your css files are all 404s. So the issue appears to be your server and not in WordPress. Please ssh/ftp/etc into your server and verify the files exist and have the correct permissions and ownership. In other words, could be a number of things wrong with your server, but the first things to look at are:

  • Do the files exist on the server in the correct location?
  • Do the files have 644 permissions?
  • Do the files have the correct owner? (Ie if you uploaded as root, root owner should be the owner of the new files. Works fine if the files already existed, uploading as root (typically) won't change this, but if they're new they'll default to the logged in user).

Check your .htaccess, remove folders and just have index.php inside of it. By folders I mean if it says eg. /new/index.php, just leave /index.php, and also check rewrite base.

You should have something like this

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

You should also check your urls in wp_options in database. If it says http://localhost/your-project/ then you need to replace it with your current url of the project that is remote.

I think you need to flash your permalink. Just go to setting>permalinks and hit save button. I hope your css file will work fine after flush your permalink. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM