我将bootstrap主题转换为wordpress。现在,我在加载引导脚本和样式时遇到了问题。 这是我的functions.php如何在functions.php(wordpress)中加载引导脚本和样式?
function wpbootstrap_scripts_with_jquery()
{
// Register the script like this for a theme:
wp_register_script('custom-script', get_template_directory_uri() . '/js/bootstrap.js', array('jquery'));
wp_enqueue_script('samplejs', get_template_directory_uri() . '/js/jquery.min.js', array(''));
wp_enqueue_script('samplejs', get_template_directory_uri() . '/js/clean-blog.min.js', array(''));
// For either a plugin or a theme, you can then enqueue the script:
wp_enqueue_script('custom-script');
}
add_action('wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery');
代码,我加入这在我的头
<?php wp_enqueue_script("jquery"); ?>
其他问题: 是什么wp_register和wp_enqueue之间的区别? 请帮帮我。 Im初学者使用bootstrap。
非常感谢你@rnevius :)怎么样的风格? – akselrows 2014-10-27 09:02:58
我用更多的解释编辑了我的答案。对于enqueueing样式,可以使用'wp_enqueue_style'在相同的函数中以相同的方式包含它们。 – rnevius 2014-10-27 09:04:04
嗯。我尝试了代码,但效果仍然不起作用 – akselrows 2014-10-27 09:06:30