对不起,我对 PHP 和 WordPress 很陌生,但我正在尝试链接到一个名为trans.js的外部 js 文件,它依赖于 jQuery。这是 header.php 开头的代码:
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/trans.js"></script>
这是functions.php中的入队
function twentytwelve_scripts_styles() {
global $wp_styles;
wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' );
function my_scripts_method() {
wp_enqueue_script(
'custom-script',
get_stylesheet_directory_uri() . '/js/trans.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
然而它仍然没有与trans.js链接——有人知道这是为什么吗?