我在实时服务器上的WordPress项目未排队JS文件(收到404错误)



我正在开发一个自定义的WordPress主题,但是一旦我将项目加载到实时服务器,它就会停止排队我的JS文件 - 并为我提供404错误。

此外,我所有加载的字体文件和CSS样式表都遇到了同样的问题

这些文件在我的本地主机上正确加载,只有在将它们加载到实时服务器上时才会中断。

我已经研究了wp_enqueue_script((和
wp_enqueue_style((,但是我仍然遇到这个问题。

我的函数.php文件包含以下脚本:

function custom_theme_scripts() {
wp_enqueue_style( 'custom-theme-style', get_stylesheet_uri(), array(), '20190512', 'all' );
wp_enqueue_script( 'jqueryScripts', get_template_directory_uri() . '/js/jqueryScripts.js', array ( 'jquery' ), 1.1, true);
}
add_action( 'wp_enqueue_scripts', 'sierra_ridge_scripts' );

上述脚本的结果是调试器控制台中显示的 404 错误。

首先,如果你检查你的代码,你可能会在add_action中调用错误的函数,你就会得到想法。

function custom_theme_scripts() {
wp_enqueue_style( 'custom-theme-style', get_stylesheet_uri(), array(), '20190512', 'all' );
wp_enqueue_script( 'jqueryScripts', get_stylesheet_directory_uri() . '/js/jqueryScripts.js', array ( 'jquery' ), 1.1, true);
}
add_action( 'wp_enqueue_scripts', 'custom_theme_scripts' );

请尝试使用此代码并再次检查。

最新更新