admin管理员组文章数量:1312805
OK , I have a Custom Theme generated by Bootstrap. Currently I just added a Navbar (navigation to the theme and I am having trouble on setting ACTIVE navbar in each active page.(by adding active
class to the li)
For example if I am in Contact us page how I can force the navbar to make the contact us nav active!
I alreadt tried
<li <?php is_page( 'Home' ){echo 'class="active"'}> Home</li>
<li <?php is_page( 'About us' ){echo 'class="active"'}> About us</li>
can you please let me know how I can do this?
OK , I have a Custom Theme generated by Bootstrap. Currently I just added a Navbar (navigation to the theme and I am having trouble on setting ACTIVE navbar in each active page.(by adding active
class to the li)
For example if I am in Contact us page how I can force the navbar to make the contact us nav active!
I alreadt tried
<li <?php is_page( 'Home' ){echo 'class="active"'}> Home</li>
<li <?php is_page( 'About us' ){echo 'class="active"'}> About us</li>
can you please let me know how I can do this?
Share Improve this question edited Nov 18, 2013 at 14:15 Mona Coder asked Nov 18, 2013 at 12:09 Mona CoderMona Coder 4062 gold badges6 silver badges20 bronze badges 1- Please edit your question to make clear and understandable what you're asking, additionally read How to Ask. – Nicolai Grossherr Commented Nov 18, 2013 at 12:29
1 Answer
Reset to default 1Looks like its just your PHP formatting, you have the right idea! try this:
<pre class="prettyprint"><code class="language-php">
<?php
if (is_page( 'Home' ) {
$class="active";
}
elseif (is_page( 'About' ) {
$class="active";
}
else {
$class="";
}
?>
<li class="<?php echo $class; ?>"Home</li>
<li class="<?php echo $class; ?>"About</li>
</code></pre>
本文标签: theme developmentSeeting Active Nav for Bootstrap in WordPress
版权声明:本文标题:theme development - Seeting Active Nav for Bootstrap in WordPress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741916054a2404737.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论