• Resolved ffgdirector

    (@ffgdirector)


    I am having trouble correcting a bit of modification to a templates code. MichaelH, one of the moderators was very helpful and was able to show me how to not display certain posts by replacing this:

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

    with this:

    if ( $the_page_id != '2' && $the_page_id != '3' && $the_page_id != '4' ) {
    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;
     }
    }

    However, now I’m having trouble getting any new pages to display. That code seems to make any pages that were added after I put it in invisible. I tried changing the pageid numbers in the code but it had no effect. Does anyone know how to correct this? I couldn’t send it in a pm to MichaelH because pm’s don’t seem to exist. So any help I can get would be appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ffgdirector

    (@ffgdirector)

    Could someone please help?

    Okay, I’ve deleted your duplicate thead…thanks for chasing me down.

    Since the goal is to have only certain pages displayed in your header, then delete the previous modifications and if necessary get the theme’s orginal header.php.

    Then change this line:

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

    to:

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

    Note: the (2,218) is retrieving page IDs 2 and 218. You will just want to add or change that list to reflect your own Page IDs.

    Thread Starter ffgdirector

    (@ffgdirector)

    Thanks! That works perfectly, and I don’t even have to go in and edit it when I edit new pages. I only have to edit it when I want them to appear. Thanks again for all the help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Need Help with showing pages; code fix’ is closed to new replies.