WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Create new pages but not have them linked to in the menu (15 posts)

  1. andy@threecoaching
    Member
    Posted 3 years ago #

    Hi,

    I want to create new pages but not have them appear in the usual list of links in the main menu. I want to link to them seperately.

    I'm sure there must be a simple way of doing this?

    thanks.

  2. Shane Hudson
    Member
    Posted 3 years ago #

    I presume your menu is in your header?

    If so, go to header.php and find something like:

    '<?php wp_list_pages(); ?>'

    To exclude pages, just add their ID to the exclude, like this:

    '<?php wp_list_pages('exclude=2,3'); ?>'

    I hope that helps,
    ~Shane Hudson

  3. Or, might be easier to use an plugin like Exclude Pages « WordPress Plugins to exclude a page from navigation rather then tweak wp_list_pages.

  4. andy@threecoaching
    Member
    Posted 3 years ago #

    Hi, thanks for the info, seems good but i have nothing like that in my header, see:

    <?php
    /**
    * The Header for our theme.
    *
    * Displays all of the <head> section and everything up till <div id="main">
    *
    * @package WordPress
    * @subpackage Twenty Ten
    * @since 3.0.0
    */
    ?>

    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    
    <head>
    	<meta charset="<?php bloginfo( 'charset' ); ?>" />
    	<title><?php
    	// Returns the title based on the type of page being viewed
    		if ( is_single() ) {
    			single_post_title(); echo ' | '; bloginfo( 'name' );
    		} elseif ( is_home() || is_front_page() ) {
    			bloginfo( 'name' ); echo ' | '; bloginfo( 'description' ); twentyten_the_page_number();
    		} elseif ( is_page() ) {
    			single_post_title( '' ); echo ' | '; bloginfo( 'name' );
    		} elseif ( is_search() ) {
    			printf( __( 'Search results for "%s"', 'twentyten' ), esc_html( $s ) ); twentyten_the_page_number(); echo ' | '; bloginfo( 'name' );
    		} elseif ( is_404() ) {
    			_e( 'Not Found', 'twentyten' ); echo ' | '; bloginfo( 'name' );
    		} else {
    			wp_title( '' ); echo ' | '; bloginfo( 'name' ); twentyten_the_page_number();
    		}
    	?></title>
    	<link rel="profile" href="http://gmpg.org/xfn/11" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    	<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    	<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    	<?php wp_head(); ?>
    </head>
    
    <body <?php body_class(); ?>>
    <div id="wrapper" class="hfeed">
    <div id="header">
    <div id="masthead">
    
    <div id="branding" align="center" onclick="location.href='http://www.threecoaching.com';" style="cursor:pointer;">
    
    <h9 class="test">Personal Trainer, Life Coach <br />
    	& Blog Author</h9>
    
    </div><!-- #branding -->
    
    <div id="access">
    <div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
    
    <?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ); ?>
    
    </div><!-- #access -->
    </div><!-- #masthead -->
    </div><!-- #header -->
    
    <div id="main">

    Any ideas?

  5. andy@threecoaching
    Member
    Posted 3 years ago #

    Ah, installed the plugin. Awesome.

    Thanks to all :)

  6. Good that it worked....

  7. beru82
    Member
    Posted 3 years ago #

    Hey, the plugins didn't worked for me but I have the same question.

    I don't want to have the pages "Imprint" & "Disclaimer" shown on my website instead I want them to be only in the footer (managed to do that at least!).

    The source code of the header.php looks like this:

    <?php
    /**
    * The Header for our theme.
    *
    * Displays all of the <head> section and everything up till <div id="main">
    *
    * @package WordPress
    * @subpackage Twenty_Ten
    * @since Twenty Ten 1.0
    */
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <title><?php
    /*
    * Print the <title> tag based on what is being viewed.
    * We filter the output of wp_title() a bit -- see
    * twentyten_filter_wp_title() in functions.php.
    */
    wp_title( '|', true, 'right' );

    ?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <?php
    /* We add some JavaScript to pages with the comment form
    * to support sites with threaded comments (when in use).
    */
    if ( is_singular() && get_option( 'thread_comments' ) )
    wp_enqueue_script( 'comment-reply' );

    /* Always have wp_head() just before the closing </head>
    * tag of your theme, or you will break many plugins, which
    * generally use this hook to add elements to <head> such
    * as styles, scripts, and meta tags.
    */
    wp_head();
    ?>
    </head>

    <body <?php body_class(); ?>>
    <div id="wrapper" class="hfeed">
    <div id="header">
    <div id="masthead">
    <div id="branding" role="banner">
    <?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
    <<?php echo $heading_tag; ?> id="site-title">
    <span>
    " title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?>
    </span>
    </<?php echo $heading_tag; ?>>
    <div id="site-description"><?php bloginfo( 'description' ); ?></div>

    <?php
    // Check if this is a post or page, if it has a thumbnail, and if it's a big one
    if ( is_singular() &&
    has_post_thumbnail( $post->ID ) &&
    ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
    $image[1] >= HEADER_IMAGE_WIDTH ) :
    // Houston, we have a new header image!
    echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    else : ?>
    <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    <?php endif; ?>
    </div><!-- #branding -->

    <div id="access" role="navigation">
    <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
    <div class="skip-link screen-reader-text">"><?php _e( 'Skip to content', 'twentyten' ); ?></div>
    <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?>
    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
    </div><!-- #access -->
    </div><!-- #masthead -->
    </div><!-- #header -->

    <div id="main">

    Anybody help?

  8. fedmich
    Member
    Posted 3 years ago #

    Try doing it via css
    .page-item-92{ display:none; }

    "92" means the page-id of the page

    Hope that helps someone.

  9. pgb
    Member
    Posted 3 years ago #

    That's helped me, thanks fedmich. I've made a child theme of twentyten and would like to exclude some pages from the main nav bar. The css works, but is there a way with php? With twentyten the wp_list_pages ('exclude=5' ) doesn't seem possible! I've looked in the header and functions but can't work out a way to do it. Does anybody have any ideas?

  10. fedmich
    Member
    Posted 3 years ago #

    You're welcome.

    did you added the code on the header.php on the child themme folder?
    it should work as I've done it before, and it worked.

  11. pgb
    Member
    Posted 3 years ago #

    No, as I'm not sure where to put the code in the child theme header or what exact code to add - twentyten is quite different. Any guidance greatly appreciated. Thanks

  12. panchodondo
    Member
    Posted 3 years ago #

    Fedmich,
    I tried to use the code
    .page-item-92{ display:none; }
    you suggested, via CSS, but... I don't know where to insert it!
    Where should I?

    The item I was trying to is this one:

    #navbar,.navbar {
    border-bottom:1px solid #000;
    width:960px;
    font-size:11px;
    font-family:Helvetica, Arial, Trebuchet MS, Verdana;
    font-style:normal;
    text-transform:uppercase;
    color:#FFFFFF;
    font-weight:bold;
    float:left;
    margin:0 auto 5px;
    padding:0;
    }

    And this is why, after all this, I wrote:

    .page_item 4 {
    display:none;
    }

    But it doesn't work.
    Help

  13. fedmich
    Member
    Posted 3 years ago #

    Can you give the link where the site is so I could investigate more?

    .page_item 4 {
    display:none;
    }

    I noticed on your code its a .page_item"<space>"4
    it should be dash
    .page-item-4{ display:none; }

    you can put that on style.css or as inline on your header.php
    <style>.page-item-4{ display:none; }</style>

    Cheers

  14. panchodondo
    Member
    Posted 3 years ago #

    Fedmich,
    Now it worked!!!
    Thank you very much indeed, my unkown webmaster.

  15. fedmich
    Member
    Posted 3 years ago #

    You're welcome :)

Topic Closed

This topic has been closed to new replies.

About this Topic