Skip to:
Content
Pages
Categories
Search
Top
Bottom

RESOLVED: Crazy WordPress question

  • @billboardfamily

    Participant

    I have tried to figure this out at other places, but nobody has a clue so I thought I would try here. I usually find answers here, you guys know your stuff. Anyway, here is the issue:

    I am trying to exclude a page in the nav menu on my site. I am using the Mensa Theme, and the

    Method is not working. Any ideas?

    Here is some code from:

    header.php

    
    <!-- BEGIN header -->
    <div id="header">
    
    <div class="search">
    <form action="/">
    <input type="text" name="s" id="s" value="" />
    <button type="submit">S</button>
    </form>
    </div>
    <div class="logo">
    <h1><a href=""></a></h1>
    </div>
    
    <ul>
    <li><a href="">Home</a></li>
    
    </ul>
    
    <div class="break"></div>
    
    </div>
    <!-- END header -->

    functions.php

    
    # Displays a list of pages
    function dp_list_pages() {
    global $wpdb;
    $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.ID ASC";
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    if ($pageposts) {
    foreach ($pageposts as $post) {
    ?><li><a href="ID); ?>">post_title; ?></a></li><?php
    }
    }
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • @mercime

    Participant

    Post header.php and functions.php at http://wordpress.pastebin.com and place URL here. Methinks it’s customization of navigation links by theme author that’s preventing you from excluding pages.

    @billboardfamily

    Participant

    @mercime

    Participant

    At least two simple ways to get back control of your pages (change brackets to curlies in codes below):

    A. delete [?php dp_list_pages(); ?] and replace it with [?php wp_page_menu( ‘exclude=5,53,75’ ); ?] in your header.php
    then delete block of code in functions.php from # Displays a list of pages to ending curly of that block (just before you reach # Displays a list of categories)

    B. If you’re on WP 3.0, you could add wp 3.0 custom navigation menus
    – replace [? php dp_list_pages(); ?] in header php and the block of code in functions.php mentioned in A with info per this article

    @billboardfamily

    Participant

    I did option A, and that worked for not listing the page in the nav bar, but it did re-order the pages alphabetically, rather than in order from lowest to highest page ID. Any ideas on how I can get this to be correctly ordered in the nav bar by page ID, rather than alphabetically?

    @mercime

    Participant

    In your case, you could do this [?php wp_page_menu( ‘sort_column=ID&exclude=2,25,253’ ); ?]
    More info at https://codex.wordpress.org/Template_Tags/wp_page_menu

    @billboardfamily

    Participant

    Outstanding. You are a lifesaver. i wish i had more experience with php, and especially wordpress. Thanks so much!

    @mercime

    Participant
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘RESOLVED: Crazy WordPress question’ is closed to new replies.
Skip to toolbar