javascript没有在所有页面上加载

时间:2015-06-19 16:16:52

标签: javascript wordpress

我的javascript文件etheme.js未加载到我的所有页面上。我正在运行最新版本的wordpress和主题。下面提供主题函数文件代码。我重新上传了备份,仍然遇到了这个问题。

            if(!function_exists('etheme_enqueue_styles')) {
            function etheme_enqueue_styles() {
            global $etheme_responsive;

            $custom_css = etheme_get_option('custom_css');

            if ( !is_admin() ) {wp_enqueue_style("fa",get_template_directory_uri().'/css/font-awesome.min.css');
            wp_enqueue_style("bootstrap",get_template_directory_uri().'/css/bootstrap.min.css');
            wp_enqueue_style("parent-style",get_template_directory_uri().'/style.css');
            if($etheme_responsive)
            wp_enqueue_style("responsive",get_template_directory_uri().'/css/responsive.css');  
            wp_enqueue_style("font-open-sans",et_http()."fonts.googleapis.com/css?family=Open+Sans:300,400,700,300italic");
            wp_enqueue_style("font-roboto",et_http()."fonts.googleapis.com/css?family=Roboto:400,500,700,300&subset=latin,cyrillic-ext");
            wp_enqueue_style('js_composer_front');

            if($custom_css) {
            wp_enqueue_style("custom",get_template_directory_uri().'/custom.css');}

            $etheme_color_version = etheme_get_option('main_color_scheme');

            if($etheme_color_version=='dark') {
            wp_enqueue_style("dark",get_template_directory_uri().'/css/dark.css');}

            $script_depends = array();
            if(class_exists('WooCommerce')) {
            $script_depends = array('wc-add-to-cart-variation');}

            wp_enqueue_script('jquery');
            wp_enqueue_script('modernizr', get_template_directory_uri().'/js/modernizr.js');
            wp_enqueue_script('head', get_template_directory_uri().'/js/head.js');
            if(class_exists('WooCommerce') && is_product())
            wp_enqueue_script('zoom', get_template_directory_uri().'/js/zoom.js',array(),false,true);
            wp_enqueue_script('etheme', get_template_directory_uri().'/js/etheme.js',$script_depends,false,true);
            wp_localize_script( 'etheme', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'noresults' => __('No results were found!', ETHEME_DOMAIN)));}}}

            add_action( 'wp_enqueue_scripts', 'etheme_enqueue_styles', 30);

1 个答案:

答案 0 :(得分:0)

尝试将此添加到您的HTML内容中:

<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>

同时尝试alert('I');查看Javascript是否有效。