Adding subpages without it appearing on the navigation bar (4 posts)

  1. JobDoctor1999
    Posted 7 years ago #


    How do I create "sub" web pages under an existing page, without it appearing under the "main page" navigation bar? For example, if you had five different "main" pages, but then wanted to include a few different pages under each of these "main" pages, but didn't want them to appear on the navigation bar, how can you do this? And can it be done without any type of plugin?

    Thank you!

  2. alainS
    Posted 7 years ago #

    Use wp_list_pages() with excluding subpages. See http://codex.wordpress.org/Template_Tags/wp_list_pages

  3. moshu
    Posted 7 years ago #

    Even better, use the "depth" parameter!

  4. inscoe2000
    Posted 7 years ago #

    How to manage/hide subpages in the main menu makes sense, but I can't find any code for wp_list_pages or a way to adjust the depth parameter. here is what I have. I'm almost pulling my hair out.

    <!-- BEGIN MAIN-NAV.PHP -->
    <!-- To show "current" on the home page -->
    <li<?php if (is_home()) { echo " id=\"current\""; } ?>>
    $pages = $wpdb->get_results("SELECT post_name, post_title, ID FROM $wpdb->posts WHERE post_type='page'");
    $getTitle=trim(wp_title(' ', false));
    foreach($pages as $page){ ?>
    	<a <?php if($check==0)echo'id="mactive"' ?> href="<?php echo get_settings('home')."/?page_id=".($page->ID); ?>"><span class="mLink"><?php echo $page->post_title; ?></span>
    		<span class="m<?php echo $page->post_title; ?>"></span>
    <?php } ?>
    <!-- END MAIN-NAV.PHP -->

    Here is the code for the header:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    if (is_home()) {
    	echo bloginfo('name'); echo ": "; echo bloginfo('description');
    } elseif (is_404()) {
    	echo '404 Not Found';
    } elseif (is_category()) {
    	echo 'Topics:'; wp_title('');
    } elseif (is_search()) {
    	echo 'Search Results';
    } elseif (is_day() || is_month() || is_year() ) {
    	echo 'Archives:'; wp_title('');
    } else {
    	echo wp_title('');
    	$subtitle = get_post_meta($post->ID, 'Subtitle', $single = true);
    	if($subtitle !== '') { echo ': ' . $subtitle; }
    } ?>
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <meta name="robots" content="all" />
    <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
    <meta http-equiv="author" content="Oleg" />
    <meta http-equiv="contact" content="http://www.metamorphozis.com/contact/" />
    <meta name="copyright" content="Copyright (c) 2005-<?php echo date("Y",time()); ?> Metamorphozis. All Rights Reserved." />
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
    <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    /***Do not Edit it***/
    	global $options;
    	foreach ($options as $value)
    		if (get_settings( $value['id'] ) === FALSE)
    			$$value['id'] = $value['std'];
    			$$value['id'] = get_settings( $value['id'] );
    	global $link_privacy,$link_terms;
    /*** End of Do not Edit Restriction***/
     <div id="menu">
    	 	<?php include (TEMPLATEPATH . '/main-nav.php'); ?>
    <div id="content">
    <!-- start header -->
    <div id="header">
    	<div id="logo">

Topic Closed

This topic has been closed to new replies.

About this Topic