How to use LESS.js with Wordpress 3
December 7, 2010 7:17 AM   Subscribe

How to integrate the less.js system correctly with Wordpress 3's raw "2010" template for local development?

I really would like to try using the less.js system for wordpress development but the way stylesheets are actually called is fairly complex. I want to do some customizing of the 2010 theme, which is structurally quite robust. But can't figure out how / where to insert the code and can't find a tutorial on this exact process anywhere.
posted by lunelson to Computers & Internet (3 answers total)
 
I think you would just insert a <script…> tag invoking less.js in the HTML header and let it do its magic. Then its up to you to recode your theme in LESS. For whatever its worth, there's also a LESS plugin for Wordpress. Not sure if that uses caching, but if so, it would be a little more efficient than having every visitor expand your LESS on the fly.
posted by adamrice at 8:53 AM on December 7, 2010


You probably just need to run wp_enqueue_script in functions.php.

Something like this should work:
function add_less_js() {

    wp_enqueue_script( "less-js", "/wp-content/themes/2010/js/less.js" );

}

add_action("init","add_less_js");
that's assuming a file named less.js in the 2010's js directory, but you can adjust the path accordingly.
posted by backwards guitar at 6:14 PM on December 7, 2010


Response by poster: Thanks for these replies!

I had come up with the wp_enqueue function too; but was hoping someone had an example of it as a complete walkthrough, maybe even a pre-treated version of the twentyten them with the appropriate functions written in? ...and calls to the latest repository for less.js of course

I made a few tries at it a while back and somehow it didn't come together; but if nothing else is forthcoming I'll give it another shot with wp_enqueue
posted by lunelson at 7:32 AM on December 11, 2010


« Older How to translate 'Let us go then, you and I' in...   |   how to get from optical to 3.5mm? Newer »
This thread is closed to new comments.