Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding page to top navigation menu

  • Profile photo of jeffreeeeey
    Tom
    Participant

    @jeffreeeeey

    (Next to “Members”, “Blogs”, etc).

    I’ve added my page via header.php copying code from one of the other links:

    <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) ) : ?> class="selected"<?php endif; ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'News', 'buddypress' ) ?></a></li>

    Here is what I added:

    <li<?php if ( bp_is_page( contact-us ) ) : ?> class="selected"<?php endif; ?>><a href="http://mysite.com/v2/contact-us/" title="<?php _e( 'Contact us', 'buddypress' ) ?>"><?php _e( 'Contact us', 'buddypress' ) ?></a></li>

    But no matter what page I am on, the “Contact us” page is highlighted. How do I change the “is is page” so that it’s only marked as selected if actually on the “contact us” page?

    As you can see… Ive changed the slug in my code, but I’ve probably done it wrong.

    Anyone know how to do it?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Profile photo of Windhamdavid
    Windhamdavid
    Participant

    @windhamdavid

    i’m not sure there is a bp_is_page ( contact ) for the function bp_nav_items() so it’s always going to render the class as “selected”. so you could just use css to highlight the list item.

    <li class="contact"><a href="http://mysite.com/v2/contact-us/" title="contact us">Contact Us</a> and then add the same css as 1.2 theme

    ul#nav li.contact a:active {background: #f5f5f5; color: #555;}

    Profile photo of jeffreeeeey
    Tom
    Participant

    @jeffreeeeey

    thanks but doesn’t that need an “if” tag added to it? If is page? Otherwise it’ll always stay highlighted.

    Profile photo of jeffreeeeey
    Tom
    Participant

    @jeffreeeeey

    To close this thread with a solution, here’s the correct, and working method:

    https://buddypress.org/forums/topic/how-to-add-a-slug-to-nav-and-link-to-a-wpmu-page?replies=5#post-33800

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding page to top navigation menu’ is closed to new replies.
Skip to toolbar