【发布时间】:2015-06-10 13:56:05
【问题描述】:
我有一个简单的问题。 这是我的 function.php enqueque 代码:
/**
*Enqueue styles.
*/
function circle_scripts() {
//load css
wp_enqueue_style( 'font-body', 'http://fonts.googleapis.com/css?family=Michroma' );
wp_register_style( 'bootstrap-style', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '1.0', 'all' );
wp_enqueue_style( 'bootstrap-style' );
wp_register_style( 'animate', get_template_directory_uri() . '/css/animate.css', array(), '1.0', 'all' );
wp_enqueue_style( 'animate' );
wp_register_style( 'myCss', get_stylesheet_uri() );
wp_enqueue_style( 'myCss' );
//load js
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', get_template_directory_uri() . '/js/jquery-1.11.3.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'jquery' );
wp_register_script( 'Bootstrap-plugin', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'Bootstrap-plugin' );
wp_register_script( 'backTop', get_template_directory_uri() . '/js/jquery.backTop.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'backTop' );
wp_register_script( 'WOW', get_template_directory_uri() . '/js/wow.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'WOW' );
wp_register_script( 'myScript', get_template_directory_uri() . '/js/myjs.js', array(), '1.0.0', true );
wp_enqueue_script( 'myScript' );
}
add_action( 'wp_enqueque_scripts', 'circle_scripts' );
但是这段代码不起作用,没有加载css和js文件。 如果我将 enqueque_style 和 enqueque_script 分开并在 header.php 和 footer.php 中调用我在 function.php 中创建的 2 个函数,它就可以工作。
【问题讨论】:
-
我解决了,wp_enqueue_scripts 而不是 wp_enqueque_scripts。
-
好的,然后批准我的答案为正确答案,以便将来帮助任何其他人获得解决方案。
标签: php wordpress function wordpress-theming