Forums

Need to exclude pages from top menu, but aint got a scooby. (11 posts)

  1. walnutmixer
    Member
    Posted 11 months ago #

    Hi everyone, does anyone know how I can exclude pages from my top menu as ive tried absalutely everything and its driving me doolaly! The code is:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Thanks for your time and effort.

  2. vtxyzzy
    Member
    Posted 11 months ago #

    You might give Simply Hide Pages plugin a try.

  3. walnutmixer
    Member
    Posted 11 months ago #

    Hi mate, cheers for the reply - I gave it a go but it hasnt worked, tried a few plug ins and none have :( I think its something in the theme code, it doesnt seem to have a wp_list_pages. Just the code above.

  4. vtxyzzy
    Member
    Posted 11 months ago #

    The 'code above' was removed according to the forum rules. Please put it in a pastebin.

  5. walnutmixer
    Member
    Posted 11 months ago #

    Sorry new here -

    <!-- ##################### PAGES MENU TOP ##################### -->
         <div style="float:right;padding-right:10px">
               <ul class="ul_big">
                    <li><a href="<?php echo get_bloginfo('siteurl');?>"><?php echo _lang('Home'); ?></a></li>
                    <?php
    
    				//post pages here
    
    				$s = "select ID, post_title from ".get_prefix()."posts where post_type='page' AND post_status='publish' order by post_title asc";
    				$r = mysql_query($s);
    
    				while($row = mysql_fetch_object($r))
    				{
    					$prm = get_permalink($row->ID);
    					echo '<li><a href="'.$prm.'">'.$row->post_title.'</a></li>';
    
    				}
    
    				?>
    
                </ul>
            </div>
          <!-- ##################### END PAGES MENU TOP #####################
  6. vtxyzzy
    Member
    Posted 11 months ago #

    One way to do this is to add a clause to the select, excluding the IDs of the posts. Assuming you want to exclude IDs 11,22,33 and 55, you would change this:

    $s = "select ID, post_title from ".get_prefix()."posts where post_type='page' AND post_status='publish' order by post_title asc";
    $r = mysql_query($s);

    to this:

    $s = "select ID, post_title from ".get_prefix()."posts where post_type='page' AND post_status='publish' ";
    $s .= "AND ID NOT IN (11,22,33,55) order by post_title asc";
    $r = mysql_query($s);
  7. walnutmixer
    Member
    Posted 11 months ago #

    Cheers for the code -

    Just to confirm the page Id can be found in the edit page primalink?

    Ive tried the code, it doesnt seem to be working as when I change the page IDs, it just removes every page from the menu exceot the home.

  8. vtxyzzy
    Member
    Posted 11 months ago #

    Please check the code very carefully. Make sure there is a space between the single and double quotes near the end of the first line:

    post_status='publish' ";

    and that the second line uses 'dot-equal', not just 'equal':

    $s .=

  9. walnutmixer
    Member
    Posted 11 months ago #

    Ill give it a go mate, but im not to certain about my IDs they're not numbers anymore as i changed them in the Primalink section, so instead of i.e. ID 12 its Business-directory

    so id replace the ID number with the label insteaD?

  10. vtxyzzy
    Member
    Posted 11 months ago #

    You need to use the numbers, not the permalinks.

    If you go to Admin->Pages, and then click 'Edit' under a Page title, you should see the Page Id in the address bar at the top of the browser window. It will be something like:

    http://yoursite.com/wp-admin/post.php?post=123&action=edit

    The number after '?post=' is the ID for that Page.

    You can also see the ID by just hovering the pointer over the Edit link and looking in the status bar at the bottom of the browser window.

  11. walnutmixer
    Member
    Posted 11 months ago #

    Ah mate you're a star! nice one fella - its worked, thanks for all your help bud :D

Reply

You must log in to post.

About this Topic