Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding Page Titles to BuddyPress Group and Forum pages

  • @jvalero

    Member

    Hello Everyone,

    I did a quick search and didn’t see any threads about what I am trying to accomplish.

    I am working on a custom nav menu for Buddypress. Each tab on the menu has a different color associated with it and the desired functionality is that when hovering over that each tab it will display the proper color and will also display the color as a signpost while each page is active. I have accomplished this for every page except for the Group and Forum (BBPress) pages. I created a script and added it to the header which dynamically inserts an id to to each pages tag, but for the group and forum pages it sets it as home. That is because the script I have automatically sets any page without a title to home as a failsafe. How do I add a pagetitle to these two pages? What files do I need to edit?

Viewing 2 replies - 1 through 2 (of 2 total)
  • @jvalero

    Member

    Well I was hoping someone would post a shorttag that I could use but I just wrote a PHP script to achieve the results I was looking for. Just in case someone else is looking to do the same here is the script I used:

    <?php
    // Set  id based on pagetitle or url for BP pages.
    $url = $_SERVER;
    $pagetitle = wp_title("","0");
    $pagetitle = strtolower(str_replace(' ', '', ltrim($pagetitle)));
    if (strlen($pagetitle) == 0 && $url == '/sbs/groups/') {
    $pagetitle = 'groups';
    } elseif (strlen($pagetitle) == 0 && $url == '/sbs/forums/') {
    $pagetitle = 'forum';
    } elseif (strlen($pagetitle) == 0 && $url == '/sbs/') {
    $pagetitle = 'home';
    }
    ?>

    How it works: It will take the pagetitle and strip it down into a web standards friendly id and insert it into the tag. If the page does not have a pagetitle set, like for example like the forums and groups pages in Buddypress then it will set a id based on the URL.

    So to insert the custom body tag id you put in <body id=&quot;">

    Hope this helps someone.

    @dannyjimmy

    Member

    Why would you want to set a body ID?

    Wouldn’t you want to set the title?
    `my buddypress title`

    My problem is that no matter where I am in forums and conversations, the page title is always just Groups.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding Page Titles to BuddyPress Group and Forum pages’ is closed to new replies.
Skip to toolbar