• Resolved bmanderson

    (@bmanderson)


    I just recently upgraded my wordpress to 2.5.1 … and I think I have everything working except for the navigation in the header. Previously I had all of my pages there (home, about, Mongolia, prayer, photos – those were the page names) – now only home and photos show up. I am an admitted code novice – but I want to learn. Could someone help me troubleshoot the following code?

    My site is https://www.remembermongolia.org

    Thanks in advance!

    <!– navigation …………………………… –>
    <div id=”navigation”>

    <form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”get”>
    <fieldset>
    <input value=”<?php echo wp_specialchars($s, 1); ?>” name=”s” id=”s” />
    <input type=”submit” value=”Go!” id=”searchbutton” name=”searchbutton” />
    </fieldset>
    </form>

      <li<?php if (is_home()) echo ” class=\”selected\””; ?>>“>Home
      <?php
      $pages = BX_get_pages();
      if ($pages) {
      foreach ($pages as $page) {
      $page_id = $page->ID;
      $page_title = $page->post_title;
      $page_name = $page->post_name;
      if ($page_name == “archives”) {
      (is_page($page_id) || is_archive() || is_search() || is_single())?$selected = ‘ class=”selected”‘:$selected=”;
      echo “<li”.$selected.”>Archives\n”;
      }
      elseif($page_name == “about”) {
      (is_page($page_id))?$selected = ‘ class=”selected”‘:$selected=”;
      echo “<li”.$selected.”>About\n”;
      }
      elseif ($page_name == “contact”) {
      (is_page($page_id))?$selected = ‘ class=”selected”‘:$selected=”;
      echo “<li”.$selected.”>Contact\n”;
      }
      elseif ($page_name == “about_short”) {/*ignore*/}
      else {
      (is_page($page_id))?$selected = ‘ class=”selected”‘:$selected=”;
      echo “<li”.$selected.”>$page_title\n”;
      }
      }
      }
      ?>

    • Photos

    </div><!– /navigation –>

Viewing 9 replies - 1 through 9 (of 9 total)
  • this isnt related specifically to your problem, however in the course of fixing that you should fix this:

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">

    it ought to be:

    <form method="get" action="<?php bloginfo('url'); ?>/">

    relying on $_SERVER['PHP_SELF'] opens you up to cross-site scripting attacks.

    Thread Starter bmanderson

    (@bmanderson)

    Thanks Whoo, fixed that.

    Now .. for the other issue. I know there’s something that’s been screwed up with this code at some point during the upgrade process. I am just not familiar enough with it to know what it is. Some help please?

    post_name in your code is the slug for pretty permalinks, and you are using default (non-pretty) permalinks. Did you used to use pretty permalinks when the code worked?

    Thread Starter bmanderson

    (@bmanderson)

    I used whatever came with the theme.

    It changed when I restored my database after an upgrade.

    So I honestly don’t know why it’s not working. I didn’t change anything.

    I will play around with the permalink settings. I don’t remember what they were before…

    The more I learn about this, the more I realize I don’t know… :s

    Thread Starter bmanderson

    (@bmanderson)

    okay I did change the permalinks to “prettier” (month/day/post). But to no avail…

    I am wondering about the \n that’s stuck in there? That doesn’t look right to me.

    A bit of track but I checked out your site and wondered how you have the archives as a drop down selection menu? I like it.

    Thread Starter bmanderson

    (@bmanderson)

    I used this bit of code for that. It’s been nice to have. Cleaned up the side bar a bit. I found it someplace online …

    <h2><?php _e(‘Archives’); ?></h2>
    <form id=”archiveform” action=””>
    <p><select name=”archive_chrono” onchange=”window.location=(document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);”>
    <option value=”>Select month</option>
    <?php wp_get_archives(‘type=monthly&format=option’); ?>
    </select></p>
    </form>

    Thanks bmanderson, very handy little bit of code!

    Thread Starter bmanderson

    (@bmanderson)

    No problem, babypress.

    For what it’s worth – I did resolve my issue. Found another way to code the header navigation menu that is much less convoluted…

    So … issue resolved … I think.

    ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Code troubleshooting help’ is closed to new replies.