【发布时间】:2017-10-07 07:42:23
【问题描述】:
我对为什么这不起作用感到非常困惑。我有一个连接到 wp_enqueue_scripts 的函数,它似乎没有调用我的函数。 我检查了我的模板中有 wp_head() 和 wp_footer() 。 这是我的代码:
functions.php
<?php
define( 'ML_DIR', get_template_directory() );
define( 'ML_URI', get_template_directory_uri() );
require ML_DIR . '/inc/enqueues.php';
?>
inc/enqueues.php
<?php
add_action( 'wp_enqueue_scripts ', 'ml_wp_enqueue_scripts' );
function ml_wp_enqueue_scripts() {
wp_register_style( 'ml-bootstrap-grid-style', ML_URI . '/assets/lib/bootsrap/bootstrap-grid.min.css' );
wp_enqueue_style( 'ml-style', ML_URI . '/style.css', array( 'ml-bootstrap-grid-style' ) );
wp_enqueue_style( 'ml-mods-style', ML_URI . '/assets/css/mods.css' );
wp_enqueue_script( 'ml-script', ML_URI . '/assets/js/scripts.js', array( 'jquery' ) );
}
?>
我在这里做错了什么?
【问题讨论】:
-
您的 html 代码中显示了什么? js和css文件链接错误?还是根本没有链接?我想建议检查一下。可能是脚本被包含但路径错误。
-
可能包含脚本文件而不是 require - 另外,这是我见过的将脚本排队的最奇怪的方式。
-
你能检查你是否在控制台中得到错误?如果是,则脚本路径不正确。否则我需要详细检查...
标签: php wordpress scripting styles themes