Html LESS不在WordPress中工作

Html LESS不在WordPress中工作,html,css,wordpress,less,wordpress-theming,Html,Css,Wordpress,Less,Wordpress Theming,如何在WordPress中运行CSS预处理器(LESS) 我试图在我的孩子主题中应用更少的内容。我创建了variable.less并将其放在子主题文件夹css/less/variable.less中,我将其称为.less,在我的样式中,类似这样的@import“variable.less” 在标题中(子主题) style.css .box-horizontal{ padding: 1em 2em 1em 2em; margin-top: -1em; text-align: center; bor

如何在WordPress中运行CSS预处理器(LESS)

我试图在我的孩子主题中应用更少的内容。我创建了
variable.less
并将其放在子主题文件夹
css/less/variable.less
中,我将其称为.less,在我的样式中,类似这样的
@import“variable.less”

在标题中(子主题)

style.css

.box-horizontal{ padding: 1em 2em 1em 2em; margin-top: -1em; text-align: center; border: 1px solid #CCC; box-shadow: @box-shadow; background: @bg-white; border-radius: 3px; }
.box-bg{ border: 1px solid #CCC; box-shadow: @box-shadow; background: #FFF; border-radius: 3px; text-align: center; }

链接:

您是否安装了较少的编译器?您需要一个来将LESS编译成CSS

我大部分时间都在使用,但还有一些插件可用。安装插件后,您可以将样式表放入
functions.php
中,如下所示:

function eq_less()
{
    wp_enqueue_style('less-style', get_stylesheet_directory_uri() . '/style.less');
}

add_action('wp_enqueue_scripts', 'eq_less', 99);
请注意
style.less
的扩展名是
.less
而不是
.css
-编译器将自动识别扩展名并为其生成一个css文件,该文件将被排队

.box-horizontal{ padding: 1em 2em 1em 2em; margin-top: -1em; text-align: center; border: 1px solid #CCC; box-shadow: @box-shadow; background: @bg-white; border-radius: 3px; }
.box-bg{ border: 1px solid #CCC; box-shadow: @box-shadow; background: #FFF; border-radius: 3px; text-align: center; }
function eq_less()
{
    wp_enqueue_style('less-style', get_stylesheet_directory_uri() . '/style.less');
}

add_action('wp_enqueue_scripts', 'eq_less', 99);