• I’m just starting out and I picked a free Studiopress theme for my site. I’ve customized it to the point that I’m getting close to liking it, except for one issue.

    When you add a subpage, it adds a tab to the top level navigation. The market street tab showing on my site is a subpage to “scattered scribbles.” I’ve done some searching but it seems most have the opposite problem: they want the tabs and don’t have it, and the offered solutions don’t match what I’m seeing.

    Is it because of the “$all_pages” in the following? What would I replace to make it only grab the top level directory for the top navigation tabs?

    Thanks Soooooo Much in advance!!

    <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>

Viewing 2 replies - 1 through 2 (of 2 total)
  • This theme is bypassing the normal WP protocol for pulling posts.

    If changing the code is acceptable to you, try changing code from this

    $these_pages = $wpdb->get_results('select ID, post_title from '. $wpdb->posts .' where post_status = "publish" and post_type = "page" order by ID');

    to this

    $these_pages = $wpdb->get_results('select ID, post_title from '. $wpdb->posts .' where post_status = "publish" and post_type = "page" and post_parent = 0 order by ID');

    The change excludes any pages that are subpages

    Thread Starter neonjade

    (@neonjade)

    You so rule, stvwlf! I’m fixed ??

    Thanks bunches.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need to remove Nav Tabs for Subpages from my theme’ is closed to new replies.