How to run the CSS preprocessor (LESS) in WordPress?
I'm trying to apply LESS in my child theme. I create variable.less
and place it in the child theme folder css/less/variable.less
and I call this .less in my style.css like this @import "variable.less"
.
LESS is not working, I tried to call the js file for less in header and in the functions.php, but not of them are worked.
I checked the console, and there's an error ../css/less/variable.less 404 (Not Found)
. But the files is there.
I tried this in the header.php (child theme)
<link rel="stylesheet/less" href="/wp-content/themes/themename-child/css/less/variable.less" type="text/css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.6.1/less.min.js"></script>
I tried this also... but no luck
function css_less(){
wp_register_script('less-js', get_template_directory_uri() . '/js/less.js');
wp_enqueue_script('less-js');
wp_register_style('less-css', get_template_directory_uri(). '/css/less/variable.less');
wp_enqueue_style('less-css');
}
add_action('wp_enqueue_scripts', 'css_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; }
Link: http://www.homecredit.ph/testEnvironment/mail-test/4830-2/