WordPress.org

Ready to get started?Download WordPress

Forums

Hide Page From Navigation (16 posts)

  1. musicteacherjobsolutions
    Member
    Posted 4 years ago #

    Hi there,

    I want to remove a page from the navigation bar so that visitors would only be able to visit this page if I gave them the URL.

    I am using Cordobo Green Park 2 theme and my URL is http://www.musicteacherjobsolutions.com.

    The URL of the page I want to hide is here:
    http://www.musicteacherjobsolutions.com/thank-you-for-your-interest-were-updating/

    I'll paste the code for my header.php below. Can someone help? I'm a total newbie at the coding aspect of WP.

    Here is the code of my header.php...thanks again.

    Julia

    <!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="X-UA-Compatible" content="IE=8" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <title><?php wp_title('»', true, 'right'); ?> <?php bloginfo('name'); ?></title>

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" />
    <!--[if IE 6]>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/ie6.css" type="text/css" />
    <![endif]-->

    <meta name="robots" content="index,follow" />
    <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'); ?>" />
    <link rel="shortcut icon" href="<?php bloginfo('stylesheet_directory'); ?>/favicon.ico" type="image/x-icon" />

    <?php
    if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'images.google.com'))
    echo '<script language="JavaScript" type="text/javascript">
    if (top.location != self.location) top.location = self.location;
    </script>';
    ?>

    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    <?php wp_head(); ?>
    </head>
    <body id="home">

    <div id="header" class="clearfix">

    <ul id="accessibility">

  2. /" title="<?php _e('Go to homepage', 'default'); ?>"><?php _e('Home', 'default'); ?>
  3. <?php _e('Content', 'default'); ?>
  4. ">RSS
  5. <?php wp_meta(); ?>
    <?php wp_register(); ?>
    <li class="last-item"><?php wp_loginout(); ?>

    <div id="branding">
    <h1 id="logo">/" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></h1>
    <div class="description">
    <?php bloginfo('description'); ?>
    </div>
    </div>

    <div id="nav" class="clearfix">
    <div id="nav-search">
    <?php get_search_form(); ?>
    </div>
    <ul id="menu">
    <li class="page-item-home <?php if ( is_home() ) { ?> current_page_item <?php } ?>">/"><?php _e('Home', 'default'); ?>
    <?php greenpark_globalnav() ?>

    <div id="submenu-bg">
    <?php if ( !is_search() && !is_404() ) {
    if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    if ($children) {
    echo "<ul id=\"submenu\">";
    echo $children;
    echo "";
    }
    } ?>
    </div>
    </div>

    </div>

    <div id="main" class="clearfix">

  • hellomatt
    Member
    Posted 4 years ago #

    Please repost the entire header.php file in between backticks (the ~ key, but don't press shift)

  • musicteacherjobsolutions
    Member
    Posted 4 years ago #

    Sorry about that...hope this works:

    <!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="X-UA-Compatible" content="IE=8" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    
    <title><?php wp_title('&raquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
    
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" />
    <!--[if IE 6]>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/ie6.css" type="text/css" />
    <![endif]-->
    
    <meta name="robots" content="index,follow" />
    <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'); ?>" />
    <link rel="shortcut icon" href="<?php bloginfo('stylesheet_directory'); ?>/favicon.ico" type="image/x-icon" />
    
    <?php
    if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'images.google.com'))
    echo '<script language="JavaScript" type="text/javascript">
    if (top.location != self.location) top.location = self.location;
    </script>';
    ?>
    
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    <?php wp_head(); ?>
    </head>
    <body id="home">
    
    <div id="header" class="clearfix">
    
    	<ul id="accessibility">
    		<li><a href="<?php echo get_option('home'); ?>/" title="<?php _e('Go to homepage', 'default'); ?>"><?php _e('Home', 'default'); ?></a></li>
    		<li><a href="#content" title="Skip to content"><?php _e('Content', 'default'); ?></a></li>
    		<li><a href="<?php if (get_option('greenpark2_feed_enable') == 'yes') { echo 'http://feeds.feedburner.com/' . get_option('greenpark2_feed_uri'); } else { echo get_bloginfo('rss2_url'); }?>">RSS</a></li>
    		<?php wp_meta(); ?>
    		<?php wp_register(); ?>
    		<li class="last-item"><?php wp_loginout(); ?></li>
    	</ul>
    
    	<div id="branding">
    		<h1 id="logo"><a href="<?php echo get_option('home'); ?>/" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a></h1>
    		<div class="description">
    		  <?php bloginfo('description'); ?>
        </div>
    	</div>
    
    	<div id="nav" class="clearfix">
    		<div id="nav-search">
    			<?php get_search_form(); ?>
    		</div>
    		<ul id="menu">
      		<li class="page-item-home <?php if ( is_home() ) { ?> current_page_item <?php } ?>"><a href="<?php echo get_option('home'); ?>/"><?php _e('Home', 'default'); ?></a></li>
      		<?php greenpark_globalnav() ?>
    		</ul>
        <div id="submenu-bg">
          <?php if ( !is_search() && !is_404() ) {
        		if($post->post_parent)
        		$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
        		else
        		$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
        		if ($children) {
        		  echo "<ul id=\"submenu\">";
              echo $children;
              echo "</ul>";
      		  }
          } ?>
        </div>
    	</div>
    
    </div>
    
    <div id="main" class="clearfix">
  • hellomatt
    Member
    Posted 4 years ago #

    Change this:

    <ul id="menu"><li class="page-item-home <?php if ( is_home() ) { ?> current_page_item <?php } ?>"><a href="<?php echo get_option('home'); ?>/"><?php _e('Home', 'default'); ?></a></li><?php greenpark_globalnav() ?></ul>

    to this:

    <ul id="menu"><li class="page-item-home <?php if ( is_home() ) { ?> current_page_item <?php } ?>"><a href="<?php echo get_option('home'); ?>/"><?php _e('Home', 'default'); ?></a></li><?php wp_list_pages('title_li=&exclude=PAGEID'); ?></ul>

    In the above code, change "PAGEID" to the page ID you wish to exclude. To find the page ID, go in your admin panel and go to the Pages section. Hover over a page and view the link, and see the "post=##". The ## is your page ID.

    Hope that helps.

  • Edward Caissie
    Theme Review Admin
    Posted 4 years ago #

    You can use a bit of CSS to "remove" a page from your navigation menus (your page listing displays, too).

    First, you will need the ID of the page you want to remove, in this case the page you linked above. For example, let's say its ID is 23.

    Add to the end of your style.css file in your active theme folder:

    .page-item-23 {display: none;} /* Removes page ID #23 from displays */
  • musicteacherjobsolutions
    Member
    Posted 4 years ago #

    Thanks! I'll give it a shot and let you know if these work!

  • hellomatt
    Member
    Posted 4 years ago #

    @cais:

    That method could work but i believe there is a more straightforward way in using wordpress' template tags.

  • Edward Caissie
    Theme Review Admin
    Posted 4 years ago #

    @hellomatt - Yes, editing the wp_list_pages() functions may be a bit cleaner from a coding perspective, but a simple line of CSS can work wonders, too.

    It would just be my preference to edit (read: add) one line of CSS versus editing at least two lines in the header and possibly more in the functions.php file under the greenpark_globalnav() call.

  • hellomatt
    Member
    Posted 4 years ago #

    You have a point, I guess it's just a matter of preference.

    It still confuses me why the theme called on globalnav. I installed the same theme, but a newer version and that function wasn't there - they are using wp_list_pages in the newer version. I installed the theme to try to see the functions.php but obviously it turned out to be irrelevant in assisting me.

  • Edward Caissie
    Theme Review Admin
    Posted 4 years ago #

    @hellomatt - I didn't go so far as to download the theme and install it to test (good job!)
    I wrote a post a while back called Hide a Menu Page that goes into more detail of using CSS this way.

  • beauty460
    Member
    Posted 4 years ago #

    Hi,

    I saw this topic and have a same problem. I need to exclude/hide some pages from my header nav bar. Below is my header.php code:

    <!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" dir="ltr" lang="en-US">
    
    <!-- BEGIN html head -->
    <head profile="http://gmpg.org/xfn/11">
    
    	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    	<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
    
    	<?php if (function_exists('wp_enqueue_script') && function_exists('is_singular')) : ?>
    	<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    	<?php endif; ?>
    	<?php wp_head(); ?>
    
    	<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/assets/css/style.css" />
    
    	<script type="text/javascript">var clear="<?php bloginfo('template_url'); ?>/assets/images/clear.gif";</script>
    
    	<!--[if lte IE 6]>
    	<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/assets/css/ie6.css" />
    	<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/assets/js/unitpngfix.js"></script>
    	<![endif]-->
    
    	<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/assets/js/jquery-1.3.2.min.js"></script>
    	<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/assets/js/jquery.cycle.all.min.js"></script>
    	<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/assets/js/scripts.js"></script>
    
    </head>
    <!-- END html head -->
    
    <body>
    
    <!-- BEGIN wrapper -->
    <div id="wrapper">
    
    	<p class="rss">
    		<a href="<?php bloginfo('rss2_url'); ?>">Posts</a> |
    		<a href="<?php bloginfo('comments_rss2_url'); ?>">Comments</a> |
    		<a href="#"></a>
    	</p>
    
    	<!-- BEGIN header -->
    	<div id="header">
    		<h1><a href="<?php echo get_option('home'); ?>"><?php bloginfo('name'); ?></a></h1>
    		<div class="ad">
    			<a href="#"><img src="<?php bloginfo('template_url'); ?>/assets/images/ad468x60.gif" alt="ad" /></a>
    		</div>
    		<div class="break"></div>
    		<ul>
    			<li><a href="<?php echo get_option('home'); ?>">Home</a></li>
    			<?php dp_list_pages(); ?>
    		</ul>
    	</div>
    	<!-- END header -->
    <div class="break"></div>
    	<!-- BEGIN body -->
    	<div id="body">
  • beauty460
    Member
    Posted 4 years ago #

    I've solved the problem. tks!

  • riffard
    Member
    Posted 4 years ago #

    I just figured out how to do it. This will allow you to exclude them, while ordering them however you want if that is your preference.

    Open up the "functions.php" file for the theme and replace the portion under
    "# Displays a list of pages". It is located in your theme (/wp-content/themes/{name of your theme's folder}/functions.php

    Replace:

    $querystr = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'page' ORDER BY $wpdb->posts.post_title ASC";

    With:

    $querystr = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'page' ORDER BY $wpdb->posts.menu_order ASC";

    It took me three days to find this, so I figure I'd share. WordPress does not have a great support system, so if you can pass this on, please do. Please copy and paste the link to this post to other inquiries.

  • gjbgraphics
    Member
    Posted 4 years ago #

    I'm not very good at all the coding. Couldn't make heads or tales of it.
    I did however find a nice little plug-in that addressed the issue for me rather well.

    "Exclude Pages from Navigation"

    ^Yep, that's the name of it.

  • Satish
    Member
    Posted 3 years ago #

    Hi all. I am posting my header.php as well. In this template there is no wp_list_pages() function and even with the "Exclude" plugin I cant seem to exclude pages from the header

    <!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">
    
    <head>
    <META name="y_key" content="0464d423d0cffaa3">
    <meta name="google-site-verification" content="MsQk2d_EXTA4tyYI5GCaUm8FSDlYuDwDP96yR0mCVLs" />
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <title><?php if (is_home () ) { bloginfo('name'); echo " - "; bloginfo('description');
    } else { wp_title('',true); echo " - "; bloginfo('name'); }?></title>
    <meta name="robots" content="index,follow" />
    <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <link rel="alternate" type="application/rss+xml" title="Satishmania" href="http://feeds.feedburner.com/Satishmania" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <?php wp_head(); ?>
    
    </head>
    
    <body>
    <div id="wrapper">
    
    <div id="header">
    <div class="topright">
    <?php include (TEMPLATEPATH . '/searchform.php'); ?>
    </div>
    </div> <!-- Closes Header -->
    
    <div class="cleared"></div>
    <div id="underheader">
    <div id="toprss"><a href="feed:<?php bloginfo('rss2_url'); ?>">
    <img src="<?php bloginfo('template_directory'); ?>/images/grabrss.gif" alt="grab our rss feed"></img></a>
    </div>
    
    <h1 class="sitename"><a href="<?php echo get_option('home'); ?>"><?php bloginfo('name'); ?></a></h1>
    <h2 class="sitedesc"><?php bloginfo('description'); ?></h2>
    
    </div><!-- Closes underHeader -->
    
    <div id="nav">
    <?php function get_the_pa_ges() {
      global $wpdb;
      if ( ! $these_pages = wp_cache_get('these_pages', 'pages') ) {
         $these_pages = $wpdb->get_results('select ID, post_title from '. $wpdb->posts .' where post_status = "publish" and post_type = "page" order by ID');
    
       }
      return $these_pages;
     }
    
     function list_all_pages(){
    
    $all_pages = get_the_pa_ges ();
    foreach ($all_pages as $thats_all){
    $the_page_id = $thats_all->ID;
    
    if (is_page($the_page_id)) {
      $addclass = ' class="current_page"';
      } else {
      $addclass = '';
      }
    $output .= '<li' . $addclass . '><a href="'.get_permalink($thats_all->ID).'" title="'.$thats_all->post_title.'"><span>'.$thats_all->post_title.'</span></a></li>';
    }
    
    return $output;
     }
    ?>
    <ul>
    <?php
    
    if (is_home()) {
      $addclass = ' class="current_page"';
      } else {
      $addclass = '';
      }
    
    echo "<li" . $addclass . "><a href='" . get_option('home') . "' title='Home'><span>Home</span></a></li>";
    echo list_all_pages();?>
    
    <?php list_all_pages('exclude=655');?>
    
    </ul>
    
    <div class="cleared"></div>
    </div> <!-- Closes Nav -->
    
    <div class="topcurvewhite"></div>
    <div id="main">
  • Satish
    Member
    Posted 3 years ago #

    to add I included the <?php list_all_pages('exclude=655');?> but it didnt do any good....

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.