我正在为客户构建我的第一个 WordPress 网站。我真的很想用LESS对于 CSS 并找到一个名为 WP-LESS 的 WP 插件.
现在,我完全是 WordPress 新手,但似乎这个插件需要我使用一个名为 wp_enqueue_style() 的函数告诉 WordPress 处理 .less 文件。
我不知道我在哪里使用这个功能。我在我的主题目录中查看了我的 header.php 文件,我看到了这个。
<link rel="stylesheet" type="text/css" media="all"
href="<?php bloginfo( 'stylesheet_url' ); ?>" />
我应该用这样的东西替换这段代码吗?
<?php wp_enqueue_style('mytheme',
get_bloginfo('template_directory').'/style.less',
array('blueprint'), '', 'screen, projection'); ?>
最佳答案
wp_enqueue_style 在主题或插件内部的用法:
wp_enqueue_style( 'my-style', get_template_directory_uri() . '/css/my-style.css', false, '1.0', 'all' ); // Inside a parent theme
wp_enqueue_style( 'my-style', get_stylesheet_directory_uri() . '/css/my-style.css', false, '1.0', 'all' ); // Inside a child theme
wp_enqueue_style( 'my-style', plugins_url( '/css/my-style.css', __FILE__ ), false, '1.0', 'all' ); // Inside a plugin
关于php - 如何在我的 WordPress 主题中使用 wp_enqueue_style()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3472087/