2017-02-14 81 views
0

wordpress主題,我有以下爲我的functions.php連接帶引導

<?php 
 
function portfolio_script_enqueue() 
 
{ 
 
\t wp_register_style('bootstrap', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css'); 
 
    $dependencies = array('bootstrap'); 
 
    wp_enqueue_style('bootstrapstarter-style', get_stylesheet_uri(), $dependencies); 
 

 
    $dependenciesScript = array('jquery'); 
 
    wp_enqueue_script('bootstrap', get_template_directory_uri().'/bootstrap/js/bootstrap.min.js', $dependenciesScript, '3.3.6', true); 
 

 
} 
 
add_action("wp_enqueue_scripts","portfolio_script_enqueue"); 
 
?>

和header.php中

<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
\t <title>My portfolio</title> 
 
\t <?php wp_head(); ?> 
 
</head> 
 
<body> 
 
<?php body_class(); ?> 
 
    
 

 

 

 
\t
但引導的造型是不是採摘。我哪裏錯了?

+0

要調用regiser_style,你必須在調用wp_enqueue_style –

回答

0

wp_enqueue_style('bootstrap');將調用註冊的風格

Accroding到WordPress抄本(https://codex.wordpress.org/Function_Reference/wp_register_stylewp register style()註冊供以後使用的CSS樣式文件,wp_enqueue_style()

因此,更改代碼爲

function portfolio_script_enqueue() 
{ 
    wp_register_style('bootstrap', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css'); 
    //enqueue the style 
     wp_enqueue_style('bootstrap');