How to make it so only main nav pages are displayed in navbar?
-
well as you can see on http://fmafans.com/ , i was wondering it was possible to make it so that the Watch FMA etc page could not be displayed there as it’s a sub page, I was wondering if it’s possible to make it so only main pages are displayed there.
-
My latest work has a list of pages in a navigation set of tabs. Here’s the code:
<div id="header"> <div id="headerimg"> <ul id="navigation"> <?php wp_list_pages('title_li=&depth=1')?> </ul> <div class="description"><?php bloginfo('description'); ?></div> </div> </div>
The “depth=1” only shows the main level of pages, not any sub-pages. This might be what you’re looking for.
doesn’t seem to be working.
Can you paste your header div in here for me to see?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="all" /> <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.easing.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.lavalamp.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/scripts.js"></script> <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?> <?php wp_head(); ?> </head> <body<?php if ( is_tag() || is_home() || is_404() || is_category() || is_day() || is_month() || is_year() ) { ?> id="home"<? } ?>> <div id="container"> <div id="header"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="subtitle"><?php bloginfo('description'); ?></div> <ul id="subscribe"> <li class="rss"><a href="<?php bloginfo('rss2_url'); ?>"><strong>Subscribe via RSS,</strong> New posts in your reader</a></li> <!--<li class="email"><a href="http://www.feedburner.com/fb/a/emailverifySubmit?feedId={FeedBurner ID}"><strong>Subscribe via E-mail,</strong> Get new posts on your e-mail</a></li>--> </ul> </div> <div id="menu"> <ul> <li<?php if ( is_home() ) { ?> class="current_page_item"<? } ?>><a href="<?php echo get_option('home'); ?>/">Home</a></li> <?php wp_list_pages('title_li=&depth=0')?> </ul> <?php if ( function_exists("get_search_form")) get_search_form(); else include (TEMPLATEPATH . '/searchform.php'); ?> </div>
You pasted in the header from your actual page output, but that’s fine. I think I see what you need.
In your WordPress template files, probably “header.php”, where you have this line:
<?php wp_list_pages('title_li=&depth=0')?>
The
depth=0
should be changed todepth=1
. I believe the0
represents unlimited levels.1
would change it to one level only.This is the original code form the header.php, i pasted the code from after I had used your advice and i was just messing around with the depth.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="all" /> <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.easing.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.lavalamp.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/scripts.js"></script> <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?> <?php wp_head(); ?> </head> <body<?php if ( is_tag() || is_home() || is_404() || is_category() || is_day() || is_month() || is_year() ) { ?> id="home"<? } ?>> <div id="container"> <div id="header"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="subtitle"><?php bloginfo('description'); ?></div> <ul id="subscribe"> <li class="rss"><a href="<?php bloginfo('rss2_url'); ?>"><strong>Subscribe via RSS,</strong> New posts in your reader</a></li> <!--<li class="email"><a href="http://www.feedburner.com/fb/a/emailverifySubmit?feedId={FeedBurner ID}"><strong>Subscribe via E-mail,</strong> Get new posts on your e-mail</a></li>--> </ul> </div> <div id="menu"> <ul> <li<?php if ( is_home() ) { ?> class="current_page_item"<? } ?>><a href="<?php echo get_option('home'); ?>/">Home</a></li> <?php wp_list_pages("title_li=") ?> </ul> <?php if ( function_exists("get_search_form")) get_search_form(); else include (TEMPLATEPATH . '/searchform.php'); ?> </div>
The code above show
<?php wp_list_pages('title_li=&depth=0')?>
and<?php wp_list_pages("title_li=") ?>
, which will both retrieve all pages.Change it to
<?php wp_list_pages('title_li=&depth=1')?>
to retrieve only the root level pages. Note the depth=1This is my code now however as you can see on the site, it’s still the same.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="all" /> <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.easing.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.lavalamp.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/scripts.js"></script> <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?> <?php wp_head(); ?> </head> <body<?php if ( is_tag() || is_home() || is_404() || is_category() || is_day() || is_month() || is_year() ) { ?> id="home"<? } ?>> <div id="container"> <div id="header"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="subtitle"><?php bloginfo('description'); ?></div> <ul id="subscribe"> <li class="rss"><a href="<?php bloginfo('rss2_url'); ?>"><strong>Subscribe via RSS,</strong> New posts in your reader</a></li> <!--<li class="email"><a href="http://www.feedburner.com/fb/a/emailverifySubmit?feedId={FeedBurner ID}"><strong>Subscribe via E-mail,</strong> Get new posts on your e-mail</a></li>--> </ul> </div> <div id="menu"> <ul> <li<?php if ( is_home() ) { ?> class="current_page_item"<? } ?>><a href="<?php echo get_option('home'); ?>/">Home</a></li> <?php wp_list_pages('title_li=&depth=1')?> </ul> <?php if ( function_exists("get_search_form")) get_search_form(); else include (TEMPLATEPATH . '/searchform.php'); ?> </div>
so any help?
- The topic ‘How to make it so only main nav pages are displayed in navbar?’ is closed to new replies.