admin管理员组

文章数量:1332345

So, I added a custom.css file in my wordpress root, now I'm wondering if it will be deleted on the next core update. Is it safe to just leave it there? Can I also create custom folders and files inside other wordpress folders like wp-content?

So, I added a custom.css file in my wordpress root, now I'm wondering if it will be deleted on the next core update. Is it safe to just leave it there? Can I also create custom folders and files inside other wordpress folders like wp-content?

Share Improve this question edited Jun 23, 2020 at 11:58 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jun 16, 2020 at 5:22 023023023023 1351 silver badge7 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 1

To answer your question directly. No the files won't get deleted when WordPress is updated. They will remain intact.

Taken from this link there are several other options for adding your own CSS, if you don't want to put it in the theme:

  1. Use Theme Options and paste in CSS
  2. Use a plugin to insert CSS/JS. You could also write your own plugin to 'host' the CSS file neatly in wp-content/plugins/ somewhere.
  3. Use a child theme, which will maintain your changes if your theme changes.

More info on each of these is in the link

Yes, those custom folders and files go inside the theme you're using. Wordpress groups files like HTML and CSS together in themes. What you should do is pop this CSS file in the directory of the theme you're using, and link to it there. Then it will definitely never get deleted, and then you have your own theme that you can apply to any Wordpress website.

So if your theme is called 'Nice Theme', you'll find a directory something like:

wp-content/themes/nice-theme

If there is a css directory in there, put your CSS in there, otherwise put it where it looks like it makes most sense, and update the point you refer to the CSS to include the extra part of the URL, e.g. if before the URL you used to load your CSS was:

https://yoursite/mycss.css

Then now it should be:

https://yoursite/wp-content/themes/nice-theme/mycss.css

本文标签: updatesIf I place custom files in Wordpress rootwill they be deleted