dongxindu8753 2017-11-25 18:33
浏览 51

Wordpress wp_enqueue_scripts()触发500内部服务器错误

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. If I comment out line 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. Here's the entire 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!

  • 写回答

1条回答

  • dtwye28880 2017-11-25 19:00
    关注

    Please use get_template_directory_uri() instead of get_stylesheet_directory_uri(). It can't work in enqueue scripts because it's for enqueueing stylesheets.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器