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 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度