-1
我在functions.php中註冊了以下腳本:wp_enqueue_script不工作
function jpmscripts() {
wp_register_script('adin-slider', get_template_directory_uri() . '/inc/js/adin-slider.js', array('jquery'));
wp_register_script('waypoints', get_template_directory_uri() . '/inc/js/jquery.waypoints.min.js', array('jquery'));
wp_register_script('skrollr', get_template_directory_uri() . '/inc/js/skrollr.min.js', array('jquery'));
wp_register_script('hammer', get_template_directory_uri() . '/inc/js/hammer.min.js', array('jquery'));
wp_register_script('jquery-hammer', get_template_directory_uri() . '/inc/js/jquery.hammer.js', array('jquery'));
wp_register_script('imagesloaded', get_template_directory_uri() . '/inc/js/imagesloaded.js', array('jquery'));
wp_register_script('jpm-home-js', get_template_directory_uri() . '/inc/js/jpm-home.js', array('jquery'));
wp_register_script('jpm-first-js', get_template_directory_uri() . '/inc/js/jpm-first.js', array('jquery'));
wp_register_style('jpm-home-css', get_template_directory_uri() . '/inc/css/jpm-home.css');
wp_register_style('jpm-first-css', get_template_directory_uri() . '/inc/css/jpm-first.css');
}
add_action('wp_enqueue_scripts', 'jpmscripts');
,我已經建立在我的主題模板文件,然後我想打電話給我的風格和scripts.i做
<?php
/*
Template Name: first
*/
?>
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div id="main">
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<title><?php wp_title('|', true, 'right'); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_head(); ?>
<?php
wp_enqueue_style('sparkling-bootstrap');
wp_enqueue_style('jpm-home-css');
wp_enqueue_script('imagesloaded');
echo "string";
?>
</head>
<body>
<div id="loading" class="loading">
...
但是沒有加載。任何樣式的任何腳本.... 請幫助我....即時通訊越來越瘋狂
感謝ü這麼多。我怎麼能在我的模板頁腳中打電話給他們? – oweb
將'true'作爲最終參數添加到'wp_enqueue_script'中。例如:''wp_enqueue_script('adin-slider',get_template_directory_uri()。'/inc/js/adin-slider.js',array('jquery'),null,true);'。有關此參數的更多信息[在Codex中](https://codex.wordpress.org/Function_Reference/wp_enqueue_script)。 – rnevius