【发布时间】:2013-11-15 18:12:13
【问题描述】:
我是 bootstrap 和 WordPress 的新手,并试图组合一个简单的页面。因此,从页眉和页脚添加和注册脚本时遇到依赖问题并不让我感到惊讶。
这里有什么明显的我遗漏的吗?
<?php
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_register_script( 'jquery-tweet', get_template_directory_uri() . 'js/jquery.tweet.js', array( 'jquery' ) );
wp_register_script( 'clock', get_template_directory_uri() . 'js/clock.js', array( 'jquery' ) );
wp_register_script( 'soon', get_template_directory_uri() . 'js/soon.js', array( 'jquery' ) );
//footer scripts
wp_register_script( 'dat-gui-min-js', get_template_directory_uri() . 'js/dat.gui.min.js' );
wp_register_script( 'fss', get_template_directory_uri() . 'js/fss.js');
wp_register_script( 'bgCustom', get_template_directory_uri() . 'js/bgCustom.js');
// For either a plugin or a theme, you can then enqueue the script:
wp_enqueue_script( 'custom-script','jquery-tweet','clock','soon','dat-gui-min-js','fss','bgCustom');
}
add_action( 'wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery' );
?>
和
在 header.php 中
<?php wp_enqueue_script("jquery"); ?>
<?php wp_head(); ?>
【问题讨论】:
-
提醒一下.. 你不需要 在标题中了。 WP 自动加载最新的 jQuery。
标签: javascript wordpress twitter-bootstrap