CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
PHP Problems
HELP !!Current_page_item nav wp_list_pages wordpress help
hal8
Permalink to comment
#
May 2010
Hi
Can anyone please help me out. I am trying to have my nav so its got an active state when on that page. I am using wp_list_pages for my nav. I know how to do this on a static site but not on Wordpress.
Can anyone help me out on this one ?
Cheers
hal8
Permalink to comment
#
May 2010
Ok so ive managed to do it kind of !!
But when i use wp_list_pages('exclude=blah, blah, blah') it seems to add an extra div automatically call pagenav
Check out the pics. One is with <?php wp_list_pages('sort_column=menu_order&title_li='); ?> and the other is the exclude.
Does any one know what i have done wrong ?
Here is my code
<div id="main-nav">
<ul>
<li<?php if (is_home()){echo " class=\"current_page_item\"";}?>><a href="<?php bloginfo('url') ?>" title="Home">Home</a></li>
<?php wp_list_pages('sort_column=menu_order&title_li='); ?>
</ul>
</div>
and css
/* MAIN NAV */
#main-nav {
float: left;
margin-top: 5px;
z-index: 70;
border: px dashed green;
}
#main-nav ul li {
display: block inline;
}
#main-nav ul li a {
color: #FFF;
padding: 5px 10px;
}
ul#smain-nav li a:hover, #shome li.home a {
border-bottom: 5px solid #FFF;
color: #008EB1;
}
#main-nav ul li a:hover, #main-nav ul li.current_page_item a {
border-bottom: 5px solid white;
color: #008eb1;
}
Add a Comment
Can anyone please help me out. I am trying to have my nav so its got an active state when on that page. I am using wp_list_pages for my nav. I know how to do this on a static site but not on Wordpress.
Can anyone help me out on this one ?
Cheers
But when i use wp_list_pages('exclude=blah, blah, blah') it seems to add an extra div automatically call pagenav
Check out the pics. One is with <?php wp_list_pages('sort_column=menu_order&title_li='); ?> and the other is the exclude.
Does any one know what i have done wrong ?
Here is my code
<div id="main-nav">
<ul>
<li<?php if (is_home()){echo " class=\"current_page_item\"";}?>><a href="<?php bloginfo('url') ?>" title="Home">Home</a></li>
<?php wp_list_pages('sort_column=menu_order&title_li='); ?>
</ul>
</div>
and css
/* MAIN NAV */
#main-nav {
float: left;
margin-top: 5px;
z-index: 70;
border: px dashed green;
}
#main-nav ul li {
display: block inline;
}
#main-nav ul li a {
color: #FFF;
padding: 5px 10px;
}
ul#smain-nav li a:hover, #shome li.home a {
border-bottom: 5px solid #FFF;
color: #008EB1;
}
#main-nav ul li a:hover, #main-nav ul li.current_page_item a {
border-bottom: 5px solid white;
color: #008eb1;
}