• Hi
    I have a problem that i cant figure out, i search at this forum but i can′t get it to work.

    I have som page that i dont want to show in the navigation menu at my home page. Then i read that you can use this code:

    <?php wp_list_pages('exclude=139,241' ); ?>

    But when it comes to my template, how and whare do i put this code ??
    The menu is in the header… And my homepage look like this https://tompe.com/wp

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="https://www.w3.org/1999/xhtml">
    
    <head>
    <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="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <link rel="icon" type="image/x-ico" href="<?php bloginfo('template_url'); ?>/images/favicon.ico" />
    <?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 ('exclude=139,241');
    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('exclude=139,241');?>
    </ul>
    
    <div class="cleared"></div>
    </div> <!-- Closes Nav -->
    
    <div class="topcurvewhite"></div>
    <div id="main">
Viewing 13 replies - 1 through 13 (of 13 total)
  • I think it is supposed to go into the header of your theme. Go to the header.php file and search for wp_list_pages, and I think you got the right code

    I would use the plugin Exclude Pages for that:

    https://www.ads-software.com/extend/plugins/exclude-pages/

    Greetings,
    Demetris

    Thread Starter mr_tompe

    (@mr_tompe)

    But thats the strange part, if you look at the code wp_list_pages is missing thats why idont know how to get it right

    I found this following code that looks similar and i tried to write it like this way (but it dont work) Sorry for my bad english

      <?php

      if (is_home()) {
      $addclass = ‘ class=”current_page”‘;
      } else {
      $addclass = ”;
      }
      echo “<li” . $addclass . “><span>Home</span>“;
      echo list_all_pages(‘exclude=139,241’);?>

    Thread Starter mr_tompe

    (@mr_tompe)

    demetris…. i tried that plugin too, but still it wont work.

    Have you looked in the header of the theme? Sometimes its in the footer, but I think thats only for the footer. Have you tried another theme?

    Thread Starter mr_tompe

    (@mr_tompe)

    I have search for “wp_list_pages” in header.php, footer.php and sidebar.php. Nothing found ?? I dont want to change the theme because i like it as it is. (exept for menu)

    I think it should be in the header.php. But the question is how to remove this two pages from the navigation menu. Any ide ?

    ———————————————————————
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
    <html xmlns=”https://www.w3.org/1999/xhtml”&gt;

    <head>
    <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=”<?php bloginfo(‘name’); ?> RSS Feed” href=”<?php bloginfo(‘rss2_url’); ?>” />
    <link rel=”pingback” href=”<?php bloginfo(‘pingback_url’); ?>” />
    <link rel=”icon” type=”image/x-ico” href=”<?php bloginfo(‘template_url’); ?>/images/favicon.ico” />
    <?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”>“>
    <img src=”<?php bloginfo(‘template_directory’); ?>/images/grabrss.gif” alt=”grab our rss feed”></img>

    </div>

    <h1 class=”sitename”>“><?php bloginfo(‘name’); ?></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 . ‘>ID).'” title=”‘.$thats_all->post_title.'”><span>’.$thats_all->post_title.'</span>‘;
    }

    return $output;
    }
    ?>

      <?php

      if (is_home()) {
      $addclass = ‘ class=”current_page”‘;
      } else {
      $addclass = ”;
      }
      echo “<li” . $addclass . “><span>Home</span>“;
      echo list_all_pages();?>

    <div class=”cleared”></div>
    </div> <!– Closes Nav –>

    <div class=”topcurvewhite”></div>
    <div id=”main”>
    ———————————————————————

    mr_tompe, it seems your theme uses its own function —get_the_pa_ges()— to generate the navigation menu. That’s why the plugin doesn’t do anything.

    Try the solution in the post by tommygun999 here:

    https://www.ads-software.com/support/topic/184902

    (It’s specifically for your theme.)

    Thread Starter mr_tompe

    (@mr_tompe)

    Thanks a lot that sounds very interesting. I have now change my code so it look like this, just as tommygun999 sad….

    But now my problem is like this, i get this error message from my browser:
    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /hsphere/local/home/tompe/tompe.com/wp/wp-content/themes/StudioPress/header.php on line 62

    and line 62 looks like this:

    $output .= ‘<li’ . $addclass . ‘>ID).'” title=”‘.$thats_them->post_title.'”><span>’.$thats_them->post_title.'</span>’;}

    Any ide what can be wrong ??

    Thread Starter mr_tompe

    (@mr_tompe)

    Thanks a lot that sounds very interesting. I have now change my code so it look like this, just as tommygun999 sad….

    But now my problem is like this, i get this error message from my browser:
    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /hsphere/local/home/tompe/tompe.com/wp/wp-content/themes/StudioPress/header.php on line 62

    and line 62 looks like this:

    $output .= ‘<li’ . $addclass . ‘>ID).'” title=”‘.$thats_them->post_title.'”><span>’.$thats_them->post_title.'</span>’;}

    Any ide what can be wrong ??

    Thread Starter mr_tompe

    (@mr_tompe)

    Could anyone look at this code and see if there is something wrong…

    $output .= ‘<li’ . $addclass . ‘>ID).'” title=”‘.$thats_them->post_title.'”><span>’.$thats_them->post_title.'</span>’;}

    Thread Starter mr_tompe

    (@mr_tompe)

    Here is some more code from my header… It must be somthing wrong in this because i get this message from webbrowser.

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /hsphere/local/home/tompe/tompe.com/wp/wp-content/themes/StudioPress/header.php on line 62

    And here is the code, i mark line 62 as bold

    <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’);
    wp_cache_add(‘these_pages’, $these_pages, ‘pages’);
    }
    return $these_pages;
    }

    function list_certain_pages($page_ids=”){
    $page_ids = explode(‘,’,$page_ids);
    $output = ”;
    $these_pages = get_the_pa_ges ();
    foreach ($these_pages as $thats_them){
    $the_page_id = $thats_them->ID;
    if (is_page($the_page_id)) {
    $addclass = ‘ class=”current_page”‘;
    } else {
    $addclass = ”;
    }
    if (isset($page_ids) && in_array($the_page_id,$page_ids)){
    $output .= ‘<li’ . $addclass . ‘>ID).'” title=”‘.$thats_them->post_title.'”><span>’.$thats_them->post_title.'</span>’;}
    }
    return $output;
    }
    ?>

    <?php

    if (is_home()) {
    $addclass = ‘ class=”current_page”‘;
    } else {
    $addclass = ”;
    }
    echo “<li” . $addclass . “><span>Home</span>”;
    echo list_certain_pages(‘5,9’);?>

    <div class=”cleared”></div>
    </div> <!– Closes Nav –>

    I’m having exactly the same problem as mr_tompe. I tried tommygun999’s solution and returned the same error message. I’ve tried three or four plugins that purport to control the nav menu, but none of them have worked.

    I have a couple of emails in to Daniel Scocca, the theme’s creator. He said he would take a look at it and see if he can figure something out.

    Maybe a little workaround will help. I’ve had the same problem.
    A page i dont want to show in the navigation menu at my home page and no plugin could help, because my theme uses the special code. Well, I did the following steps:

    1. Make it private
    Set the status of your page to “private”. The page should disapear in the main-navigation.

    2. Make your private page visible
    The problem is, that only you can see your private page. to make it visibible for everyone, install an activate the role manager plugin: link

    Now, activate the option “view private pages” for every role. The private site is now visible for every visitor of your blog.

    3. Hide the “private” status in the headline
    The word Private is shown in the headline of the page. To make it disapear just copy and paste the following code to the functions.php in your theme.

    <?php
    /*
    Plugin Name: CyTBRemovePrivatePrefix
    Version: 0.1
    Plugin URI: www.cywhale.de
    Description: Entfernt 'Privat: '-Prefix von Beitragstiteln
    Author: Cywhale
    Author URI: www.cywhale.de
    Min WP Version: 2.3
    Max WP Version: 2.6
    */
    
    /*
     * Filterfunktion für the_title
     * Entfernt 'Privat:' oder 'Private:' Prefixe von Beitragstiteln
     * @param string $title, Beitragstitel
     * @return string, Umgewandelter Titel
     */
    
    function cyTB_removePrivate($title) {
        return(preg_replace( '=^(Privat|Private)\:[\ +]=','', $title));
    }
    
    // Filter anmelden
    add_filter('the_title','cyTB_removePrivate');
    ?>

    This should work fine for you.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to exlude some pages in the nav. menu ??’ is closed to new replies.