简体   繁体   English

如何将样式表添加到WordPress后端的CSS编辑器中?

[英]How can I add my stylesheets to the CSS editor in the WordPress backend?

I have created a custom theme in WordPress, with its own set of stylesheets in a CSS directory. 我已经在WordPress中创建了一个自定义主题,并在CSS目录中使用了自己的一组样式表。 I want to be able to edit them through the WordPress backend (ie through Appearance>Editor). 我希望能够通过WordPress后端(即通过外观>编辑器)对其进行编辑。

I presume it will just be a couple of lines of code to add to functions.php , but I have searched around and can't find anything that will work out (I'm thinking because most of the solutions I've found are 4 years old...and WordPress has been updated a few times since then). 我想这只是将几行代码添加到functions.php ,但是我四处搜索,找不到任何可行的方法(我在想,因为我发现的大多数解决方案都是4年......此后WordPress已进行了几次更新)。

I tried adding filters and playing with wp_enqueue_style to no avail. 我尝试添加过滤器并使用wp_enqueue_style无效。 Thanks for any help anyone can offer. 感谢您提供任何帮助。

All files within your themes folder and sub-folders will be listed for editing under the theme editor. 主题文件夹和子文件夹中的所有文件都会在主题编辑器下列出以供编辑。

I just checked under WordPress 3.8.1 and even files located under a sub-folder within my themes folder are all being listed. 我只是在WordPress 3.8.1下进行了检查,甚至列出了位于主题文件夹下子文件夹下的文件。

Make sure there are no errors in your css files that prevent it from being opened in the theme editor. 确保您的css文件中没有错误,阻止其在主题编辑器中打开。

Additionally, despite files located in sub-folders still being listed in the theme editor, for some reason the theme editor will not list css files in sub-folders. 此外,尽管位于子文件夹中的文件仍在主题编辑器中列出,但出于某种原因,主题编辑器不会在子文件夹中列出css文件。 You will have to place your other css files in the root folder of your theme. 您将不得不将其他css文件放在主题的根文件夹中。

Move your css files to your themes root folder and you will be able to edit them in the WordPress theme editor. 将css文件移动到主题根文件夹,您将可以在WordPress主题编辑器中对其进行编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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