Wordpress插件问题css和js未加载

时间:2012-12-26 07:47:56

标签: wordpress wordpress-plugin

我在我的频道主题中使用wordpress captain slider plugin我不知道为什么css和js没有加载。没有权限问题任何帮助???

这些是加载到wp-contents / plugins / captain-slider / captain-slider.php

function ctslider_load_scripts() {
    wp_register_style( 'flexslider-style',  CTSLIDER_PLUGIN_URL . 'includes/css/flexslider.css', array(  ), CTSLIDER_VERSION );

    wp_register_script( 'flexslider',  CTSLIDER_PLUGIN_URL .  'includes/js/jquery.flexslider-min.js', array( 'jquery' ), CTSLIDER_VERSION, false );
    wp_register_script( 'fitvids',  CTSLIDER_PLUGIN_URL . 'includes/js/jquery.fitvids.js', array( 'jquery' ), CTSLIDER_VERSION, false );

    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'flexslider' );
    wp_enqueue_script( 'fitvids' );

    wp_enqueue_style( 'flexslider-style' ); 
}
add_action( 'wp_enqueue_scripts', 'ctslider_load_scripts' );

1 个答案:

答案 0 :(得分:-1)

此代码似乎完全错误。当触发wp_enqueue_scripts操作时,正在执行函数ctslider_load_scripts()。因此,所有脚本都会在操作触发后排队。这是错误的。

请勿使用此操作。只需将脚本排入队列:

wp_register_style( 'flexslider-style',  CTSLIDER_PLUGIN_URL . 'includes/css        /flexslider.css', array(  ), CTSLIDER_VERSION );

wp_register_script( 'flexslider',  CTSLIDER_PLUGIN_URL .  'includes/js/jquery.flexslider-min.js', array( 'jquery' ), CTSLIDER_VERSION, false );
wp_register_script( 'fitvids',  CTSLIDER_PLUGIN_URL . 'includes/js/jquery.fitvids.js', array( 'jquery' ), CTSLIDER_VERSION, false );

wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'flexslider' );
wp_enqueue_script( 'fitvids' );

wp_enqueue_style( 'flexslider-style' );