我正在使用本地主機上的Bootstrap使用Wordpress主題。 我已經正確加載CSS文件,並且使用正確的方式加載了js文件,但由於某些原因,js腳本無法正常工作。我的WordPress,Bootstrap主題不適用於JavaScript
這裏是我的index.php
<?php get_header(); ?>
<?php get_footer(); ?>
這裏是我的header.php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href = "<?php bloginfo(stylesheet_url); ?>" rel = "stylesheet">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Start Bootstrap</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a href="#about">About</a>
</li>
<li>
<a href="#services">Services</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
這裏是我的footer.php
<script src= "<?php get_template_directory(); ?>/js/bootstrap.js"></script>
</body>
</html>
此問題驅動器我瘋了! 我花了2個小時尋找解決方案,但沒有任何!
那麼問題是什麼傢伙?
使用正確的入隊('wp_enqueue_script')函數,不要手動添加腳本標籤 - 這是一個壞習慣 – naththedeveloper
你能向我解釋如何使用它嗎? –
'我已經正確加載CSS文件',你怎麼這麼確定?因爲我知道你沒有 –