How to get current Buddypress page name?

I am trying to dynamically display the name of the page a user is on in Buddypress. For example if you are on the Notifications page, I need a variable that displays “Notifications”.

I’m looking for something that works such as the_title(); for WordPress.

Related posts

Leave a Reply

2 comments

  1. <?php echo (bp_current_component());?>
    

    This might do the trick..

    if you want the whole code for the tag for your header.php file then you can use the code given below.(You can always customize as per your need)

    <title>
    
        <?php if ( is_home() ) { ?><? bloginfo('name'); ?>&nbsp;|&nbsp;<?php bloginfo('description'); ?><?php } ?>
    
        <?php if ( is_search() ) { ?><? bloginfo('name'); ?>&nbsp;|&nbsp;Search Results<?php } ?>
    
        <?php if ( is_author() ) { ?><? bloginfo('name'); ?>&nbsp;|&nbsp;Author Archives<?php } ?>
    
        <?php if ( is_single() ) { ?><?php wp_title(''); ?>&nbsp;|&nbsp;<? bloginfo('name'); ?><?php } ?>
    
        <?php if ( is_page() ) { ?><? bloginfo('name'); ?>&nbsp;|&nbsp;<?php wp_title(''); ?><?php } ?>
    
        <?php if ( is_category() ) { ?><? bloginfo('name'); ?>&nbsp;|&nbsp;Archive&nbsp;|&nbsp;<?php single_cat_title(); ?><?php } ?>
    
        <?php if ( is_month() ) { ?><? bloginfo('name'); ?>&nbsp;|&nbsp;Archive&nbsp;|&nbsp;<?php the_time('F'); ?><?php } ?>
    
        <?php if (function_exists('is_tag')) { if ( is_tag() ) { ?><? bloginfo('name'); ?>&nbsp;|&nbsp;Tag Archive&nbsp;|&nbsp;<?php  single_tag_title("", true); } } ?>
    
        <?php echo bp_get_displayed_user_fullname();?>&nbsp;|&nbsp;<?php echo ucfirst(bp_current_component());?>
    
    </title>
    

    That’s my site’s code as it is so you might want to customize for you

  2. Check out the BuddyPress Template Tag Reference

    There you will find functions such as bp_is_messages_conversation() and bp_is_change_avatar()

    These can be used like this:

    if ( bp_is_change_avatar() ) {
        // You are currently viewing the change avatar screen
    } else {
        // You are not viewing the change avatar screen
    }
    

    Regarding notifications, I’m not sure if there is a ‘wrapper’ function available but you could do something like this:

    if ( bp_is_current_action( 'unread' ) ) {
        // You are viewing the unread notifications screen
    }
    

    or:

    if ( bp_is_current_action( 'read' ) ) {
        // You are viewing the read notifications screen
    }