[英]Wordpress wp_enqueue_scripts() triggers 500 Internal Server Error
I'm editing a functions.php
file in a child version of a WordPress theme in order to load a custom javascript filmScript.js
, which exists, but is currently empty. 我正在WordPress主题的子版本中编辑
functions.php
文件,以加载自定义javascript filmScript.js
,该filmScript.js
存在但目前为空。 If I comment out line 10 如果我注释掉第10行
wp_enqueue_scripts( 'myVideo', get_stylesheet_directory_uri() . '/assets/js/filmScript.js', array('jquery'), '1.0.0', false );
everything works: echo statements log to the console, the page loads, etc. However, when the line is being read the page breaks and throws a 500 Internal Server Error
. 一切正常:echo语句记录到控制台,页面加载等。但是,在读取行时,页面中断并抛出
500 Internal Server Error
。 Here's the entire functions.php: 这是整个functions.php:
<?php
add_action( 'wp_enqueue_scripts', 'video_bg', 10);
add_action( 'after_setup_theme', 'post_theme_setup' );
if ( !function_exists( 'post_theme_setup' )):
function post_theme_setup(){
function video_bg() {
wp_enqueue_scripts( 'myVideo', get_stylesheet_directory_uri() . '/assets/js/filmScript.js', array('jquery'), '1.0.0', false );
echo '<script>console.log("Script added?")</script>';
}
add_action( 'wp_enqueue_scripts', 'video_bg', 10);
echo '<script>console.log("Action added")</script>';
}
endif;
Any thoughts? 有什么想法吗? Thanks!
谢谢!
Please use get_template_directory_uri()
instead of get_stylesheet_directory_uri()
. 请使用
get_template_directory_uri()
而不是get_stylesheet_directory_uri()
。 It can't work in enqueue scripts because it's for enqueueing stylesheets. 它不能用于排队脚本,因为它用于排队样式表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.