2016-04-07 34 views
0

WordPress'te CSS önişlemcisi (LESS) nasıl çalıştırılır?LESS WordPress'te çalışmıyor

Çocuk temamda LESS'i uygulamaya çalışıyorum. Ben variable.less oluşturmak ve çocuk teması dizinde css/less/variable.less yerleştirin ve başlık (çocuk teması) bu @import "variable.less"

gibi benim style.css bu .less diyoruz

<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> 

ama işe yaramıyor.

Ben de bu çalıştı ... ama hiçbir şans

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; } 

Bağlantı: Bir AZ-derleyici yüklü http://www.homecredit.ph/testEnvironment/mail-test/4830-2/

cevap

0

sen var mı? LESS'i CSS'ye derlemek için birine ihtiyacınız var.

Çoğu zaman https://wordpress.org/plugins/wp-less/ kullanıyorum, ancak daha fazla eklenti var. Eklentiyi yükledikten sonra böyle senin functions.php içinde stil enqueue edebilirsiniz:

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 değil .css olduğu uzatılmasını unutmayın - otomatik uzantısı tanıması ve bunun için bir css dosyası üretecektir derleyici hangi meçhul

+1

lessphp ayrıca kullanışlıdır: http://leafo.net/lessphp/ – admcfajn