Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to add a slug to nav and link to a WPMU page


  • pcwriter
    Participant

    @pcwriter

    Hi all!

    I’m feeling quite proud of myself this evening and just had to share this.

    Thanks to the great folks in these here forums, I (a true-blue php-dummy) figured out how to add a new slug to the main navbar, link it to a WPMU page and highlight the slug when on the page. Hooray!

    1 – Define the slug in wp-config.php, just before the line where it says “Stop Editing!” like so:

    define ( “BP_PAGE_SLUG”, ‘wpmu-page-name‘ );

    2 – Add the slug into header.php (somewhere around line 87) like so:

    <li<?php if ( is_page( BP_PAGE_SLUG ) ) : ?> class=”selected”<?php endif; ?>>/<?php echo BP_PAGE_SLUG ?>” title=”<?php _e( ‘Slug Label‘, ‘buddypress’ ) ?>”><?php _e( ‘Slug Label‘, ‘buddypress’ ) ?>

    3 – Make sure that ?php if ( bp-is_page is truncated to ?php if ( is_page

    Removing the “bp-” ensures that, when linking to a WPMU created page, the slug is properly highlighted when on that page.

    It works. Thanks to all who contribute here. Now I can go to bed a little more knowledgeable.

Viewing 4 replies - 1 through 4 (of 4 total)

  • Tom
    Participant

    @jeffreeeeey

    Thanks for this my friend.. exactly what I am looking for. However can you please re-post the code in code tags so it displays correctly?

    Also.. the parts you have made in bold- do I replace those parts with the slug of my WPMU page slug?


    pcwriter
    Participant

    @pcwriter

    <li<?php if ( is_page( BP_PAGE_SLUG ) ) : ?> class="selected"<?php endif; ?>>/<?php echo BP_PAGE_SLUG ?>" title="<?php _e( 'Slug Label', 'buddypress' ) ?>"><?php _e( 'Slug Label', 'buddypress' ) ?></li>


    pcwriter
    Participant

    @pcwriter

    Replace BP_PAGE_SLUG with BP_YOUR-SLUG-NAME_SLUG in both wp-config.php and header.php

    Replace Slug Label in header.php with the text you want to appear on the slug.


    Tom
    Participant

    @jeffreeeeey

    OK After a lot of messing about with that code mate, I’ve finally got it.

    The link I was trying to add was ‘prizes’, and prizes page had the slug ‘prizes’. Here’s what I had to do-

    In my header.php I added:

    <li<?php if ( is_page( BP_prizes_SLUG ) ) : ?> class="selected"<?php endif; ?>><a href="<?php echo BP_prizes_SLUG ?>" title="<?php _e( 'prizes', 'buddypress' ) ?>"><?php _e( 'prizes', 'buddypress' ) ?></a></li>

    And in wp-config.php I added:

    // Page slug naming for top nav
    define ( "BP_prizes_SLUG", 'prizes' );

    Working fine now. Thanks for the guidance :-)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to add a slug to nav and link to a WPMU page’ is closed to new replies.
Skip to toolbar