• Resolved Galaxy_High

    (@galaxy_high)


    Hello all,

    Is there a way to keep the navigation highlighted when posts are selected within a page?

    Similar to this…

    *Home* About News Contact <–Pages using wp_list_pages

    postID_whatever content <–Posts

    Thanx in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Galaxy_High

    (@galaxy_high)

    OK, i kind of got something working without using the wp_list_pages and instead using this:

    <ul>
    <li class="page_item<?php if ( is_page('home') ) { echo ' current_page_item'; } ?>"><a href="/axis/">Home</a></li>
    <li class="page_item<?php if ( is_page('spades') || in_category('spades') ) { echo ' current_page_item'; } ?>"><a href="/axis/spades">Spades</a></li>
    <li class="page_item<?php if ( is_page('hearts') || in_category('hearts') ) { echo ' current_page_item'; } ?>"><a href="/axis/hearts">Hearts</a></li>
    <li class="page_item<?php if ( is_page('clubs') || in_category('clubs') ) { echo ' current_page_item'; } ?>"><a href="/axis/clubs">Clubs</a></li>
    <li class="page_item<?php if ( is_page('diamonds') || in_category('diamonds') ) { echo ' current_page_item'; } ?>"><a href="/axis/diamonds">Diamonds</a></li>
    <li class="page_item<?php if ( is_page('contact') ) { echo ' current_page_item'; } ?>"><a href="/axis/contact">Contact</a></li>
    </ul>

    Is there no way to implement this using the wp_list_pages function?

    yeah, there is… list pages will output a whole bunch of CSS classes one of which will be unique to the current page.

    Look at the HTML it makes, then put the class name into your CSS and style it accordingly.

    Thread Starter Galaxy_High

    (@galaxy_high)

    Hi Katya,

    I have seen that but I want the navigation to remain highlighted when posts are selected within a page.

    So it is similar to this:

    *Spades*>Post-whatever

    I think you’re using pages incorrectly… because posts aren’t actually within pages, they’re within categories.

    I think what you want instead of using pages, is to use category templates as a kind of page — I think that will make this whole process much easier.

    I don’t know if you’re using the right terminology do you really mean posts, or do you mean sub-pages?

    From what you’ve shown here, it looks like you’re trying to make breadcrumb navigation – there are plugins which will do that for you out of the box.

    Thread Starter Galaxy_High

    (@galaxy_high)

    I have a page, say, Spades.

    I then have a post, say, Ace with a category name: spades.

    When you click on the Spades link in the navigation all the post related to category spades are listed.

    Does this make sense?

    yes, it makes sense, but only because you’re using a fakeout based on the page name and category names instead of just using wp_list_categories in the first place, instead of wp_list_pages.

    I think your problem goes away if you use wp_list_categories – the css generated by that lets you keep the parent category highlighted.

    Thread Starter Galaxy_High

    (@galaxy_high)

    Figured it out.

    WordPress didn’t like me renaming the default category (can’t remember the name of it).

    So, I renamed the problem category to default and created a new category with the old name and associated all posts to it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Styling navigation’ is closed to new replies.