Skip to:
Content
Pages
Categories
Search
Top
Bottom

Conditional Tag Questions (specifically bp_is_user_profile)

  • Avatar of madyogi
    madyogi
    Participant

    @madyogi

    Basically, I am needing to find a way to include one header/footer combination for all buddypress pages across my site, while dispalying another header/footer combination on other WPMU pages not related to the social networking functionality of BP.

    After getting some help from these forums, I thought I could just stick some if…elseif….else code in header.php that would do the following:

    if (PAGE IS BUDDYPRESS RELATED) include header-buddypress.php;
    elseif (PAGE IS ABOUT PAGE) include header-about.php;
    else include header-home.php

    I figured I could do the same with the footers. It seemed on the face of it that this should be fairly simple using conditional tags, but they aren’t functioning as I expected.

    For example, this code in my header.php file

    <?php if ( bp_is_user_profile() ) {
    get_header(bpProfile); //include bpProfile header if page is a bp profile page
    } elseif ( is_page('Why We're Here') ) {
    get_header(about); //include about header if page is not a profile page
    } else {
    get_header(home); //include normal home header in all other cases
    } ?>

    always produces the bpProfile header. If I echo bp_is_user_profile, it always comes back as “1,” no matter what page I’m on with WPMU, whether I’m logged in or not.

    I am kind of befuddled at this point. Perhaps I’m going about this the wrong way, but I just figured this would be the best way to modify a child theme to my specifications by just having a few custom header/footer files that are included as needed each time a page calls get_header(); and get_footer();

    Does anyone have any thoughts on this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of toddlevy
    toddlevy
    Participant

    @toddlevy

    for bp_is_user_profile(), you can use this…

    <?php

    global $bp;

    if($bp->current_component == BP_XPROFILE_SLUG) {

    //Your code here

    }

    ?>

    Found this tip here… http://buddypress.org/forums/topic/show-specific-content-on-profile-page-only#post-26739

    Avatar of madyogi
    madyogi
    Participant

    @madyogi

    Okay, so I followed your advice, toddlevy, but for whatever reason, I’m still getting my profile header the home page. The following is in my header.php file:

    <?php

    global $bp;

    if ($bp->current_component == BP_XPROFILE_SLUG) {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/communityHeaderTest.php'); //include this header on BuddyPress profile pages
    } elseif ( is_home() ) {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/homeHeader.php'); //include this header on home page
    } elseif ( is_single() ) {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/homeHeader.php'); //include this header on posts
    } elseif ( is_page('Why We're Here') ) {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/homeHeader.php'); //include this header on about page
    } else {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/communityHeader.php'); //include this header on BuddyPress pages
    } ?>

    Any ideas as to why this would include communityHeaderTest.php on the home and about pages? Single pages are including the correct header.

    I have been working with this code in my header, which seems to work for what I need:

    <?php

    if ( is_home() ) {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/homeHeader.php'); //include this header on home page
    } elseif ( is_single() ) {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/homeHeader.php'); //include this header on posts
    } elseif ( is_page('Why We're Here') ) {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/homeHeader.php'); //include this header on about page
    } else {
    include (TEMPLATEPATH . '/../ARHealthCareersFrameTheme/customHeaders/communityHeader.php'); //include this header on BuddyPress pages
    } ?>

    Still, it seems like I should just be able to use the BP conditionals to find out which specific BP page I’m on and display content accordingly.

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

You must be logged in to reply to this topic.