2016-03-02 43 views
0

我从一个静态站点创建我的第一个wordpress主题,该站点由CDN提供的Boostrap运行。使用最新的Boostrap通过Wordpress通过MAXCDN交付

请不要有任何建议来下载此项目的boostrap,它需要通过CDN交付。

我想通过CDN使用我的functions.php文件加载boostrap,而不是加载它只是显示在加载页面的顶部的文本(没有任何明显的检查员pannel和没有错误消息它只是似乎显示来自functions.php的信息作为文本)。

我已经包含在header.php中

所有的functions.php中码<?php wp_head(); ?>

function my_scripts_enqueue() { 
    wp_register_script('bootstrap-js', '://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', array('jquery'), NULL, true); 
    wp_register_script('gajax-js', '://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js', array('jquery'), NULL, true); 
    wp_register_style('bootstrap-css', '://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', false, NULL, 'all'); 
    wp_register_style('fontawsome-css', '://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', false, NULL, 'all'); 

    wp_enqueue_script('bootstrap-js'); 
    wp_enqueue_script('gajax-js'); 
    wp_enqueue_style('bootstrap-css'); 
    wp_enqueue_style('fontawsome-css'); 
} 
add_action('wp_enqueue_scripts', 'my_scripts_enqueue'); 

回答

0

如果你想要的一切,从CDN,你必须摆脱默认的jQuery的期待在后台或登录屏幕上。

之后,你刚才添加的CDN没有 “:”

add_action('wp_enqueue_scripts', 'register_jquery'); 
function register_jquery() { 
    if (!is_admin() && $GLOBALS['pagenow'] != 'wp-login.php') { 
     wp_deregister_script('jquery'); 

     wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', false, '1.11.2'); 
     wp_register_script('bootstrap-js', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', array('jquery')); 

     wp_register_style('bootstrap-css', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'); 
     wp_register_style('fontawsome-css', '//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'); 

     wp_enqueue_script('jquery'); 
     wp_enqueue_script('bootstrap-js'); 

     wp_enqueue_style('bootstrap-css'); 
     wp_enqueue_style('fontawsome-css'); 
    } 
}