• dwzemens

    (@dwzemens)


    I am using 2.1 and have successfully done dynamic navigation on several sites using “page_item” and “current_page_item” invoked by wp_list_pages(). I am having problems on one site. I have assigned the “Home” page as the static front page and a page called “Blog” as the post page alternative. For some reason, the Blog page does not dynamically highlight that navigation link because wp_list_pages() is not throwing the “current_page_item” into the HTML.

    Can anyone think of a reason why this is occurring? “Blog” is a “page”, and I see the the WP documentation says that “current_page_item” is applied as follows: “When wp_list_pages is called while displaying a Page, the list item for that Page will be given the additional class “current_page_item”. So, I have concluded that for some reason WP is not seeing the “Blog” page as a “page”. Make sense? Any help appreciated.

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

    (@dwzemens)

    Still struggling with this problem, and I am bumping this post to the top. Thanks for any help you can offer.

    spencyb

    (@spencyb)

    Here’s how I solved this problem. I can’t tell you why it works, but I can tell you that I figured this out by messing around for a couple hours. Here’s what I wrote for my nav:

    <ul id="nav">
         <?php if (!is_single() && !is_page()): ?>
              <li><a href="/">Home</a></li>
    	  <li class="page_item current_page_item"><a href="/clips">Clips</a></li>
              <?php wp_list_pages('exclude=141,158&sort_column=menu_order&title_li='); ?>
         <?php else : ?>
              <?php wp_list_pages('sort_column=menu_order&title_li='); ?>
              <li class="page_item rss"><a href="<?php bloginfo('atom'); ?>">RSS</a></li>
         <?php endif; ?>
    </ul>

    I have a static home page and a posts page defined in WordPress and this code makes everything highlight properly.

    In “exclude=141,158” 141 and 158 are my the page IDs of my home page and index pages respectively (be sure to write the lower number first). In “a href=”/clips”>Clips” clips and Clips are the page slug and page name of my index page.

    You can check it out in action on my sandbox page (which is liable to go down and/or change.)

    Thread Starter dwzemens

    (@dwzemens)

    SpencyB,

    My problem was that 2.1 *should* do this automatically. I used to use your technique before WP recognized a static home page. Thanks just the same.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem with “current_page_item” not displaying when using wp_list_pages()’ is closed to new replies.