Breadcrumb for BP-Business?

Good day :slight_smile:

How can i have a Breadcrumb Navigation in the BP-Business-Theme? Is there an easy way to adapt the breadcrump-component of BP-Daily?

Thanks in advance,
Rainer.

  • Tammie

    @rainerkormann: I've not tried this but the theory should be the following:

    1. Create a file called custom-functions.php and save it under /includes/ add in there the following:


    <?php
    function wpbreadcrumbs(){
    if (is_page() && !is_front_page() || is_single() || is_category()) {
    echo '<ul class="breadcrumbs">';
    echo '<li class="front_page">'.get_bloginfo('name').'';

    if (is_page()) {
    $ancestors = get_post_ancestors($post);

    if ($ancestors) {
    $ancestors = array_reverse($ancestors);

    foreach ($ancestors as $crumb) {
    echo '

  • '.get_the_title($crumb).'
  • ';
    }
    }
    }

    if (is_single()) {
    $category = get_the_category();
    echo '

  • cat_ID).'">'.$category[0]->cat_name.'
  • ';
    }

    if (is_category()) {
    $category = get_the_category();
    echo '

  • '.$category[0]->cat_name.'
  • ';
    }

    // Current page
    if (is_page() || is_single()) {
    echo '<li class="current">'.get_the_title().'';
    }
    echo '';
    } elseif (is_front_page()) {
    // Front page
    echo '<ul class="breadcrumbs">';
    echo '<li class="front_page">'.get_bloginfo('name').'';
    echo '<li class="current">'.__( 'Home', 'bp-daily' ).'';
    echo '';
    }
    }

    function bpbreadcrumbs(){
    if (is_page() && !is_front_page() || is_single() || is_category()) {
    echo '<ul class="breadcrumbs">';
    echo '<li class="front_page">'.get_bloginfo('name').'';

    if (is_page()) {
    $ancestors = get_post_ancestors($post);

    if ($ancestors) {
    $ancestors = array_reverse($ancestors);

    foreach ($ancestors as $crumb) {
    echo '

  • '.get_the_title($crumb).'
  • ';
    }
    }
    }

    if (is_single()) {
    $category = get_the_category();
    echo '

  • cat_ID).'">'.$category[0]->cat_name.'
  • ';
    }

    if (is_category()) {
    $category = get_the_category();
    echo '

  • '.$category[0]->cat_name.'
  • ';
    }

    // Current page
    if (is_page() || is_single()) {
    $title = get_the_title();
    if ($title != ""){
    echo '<li class="current">'.get_the_title().'';
    }
    }
    }
    if (bp_is_page( BP_ACTIVITY_SLUG )){
    echo '

  • '.__( 'Activity', 'bp-daily' ).'
  • ';
    }
    if (bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member()){
    echo '<li class="current">'.__( 'Members', 'bp-daily' ).'';
    }
    if (bp_is_page( BP_GROUPS_SLUG ) || bp_is_group()){
    echo '<li class="current">'.__( 'Groups', 'bp-daily' ).'';
    }
    if (bp_is_page( BP_FORUMS_SLUG )){
    echo '<li class="current">'.__( 'Forums', 'bp-daily' ).'';
    }
    if (bp_is_page( BP_BLOGS_SLUG )){
    echo '<li class="current">'.__( 'Blogs', 'bp-daily' ).'';
    }
    echo '';

    if (is_front_page()) {
    // Front page
    echo '<ul class="breadcrumbs">';
    echo '<li class="front_page">'.get_bloginfo('name').'';
    echo '<li class="current">'.__( 'Home', 'bp-daily' ).'';
    echo '';
    }
    }
    ?>

    2. Add this line into functions.php after line 146 before the close brace *do not remove closing brace:

    include ($includes_path . 'custom-functions.php');

    3. Where you want the breadcrumbs to appear add the following code:

    <div id="breadcrumb">
    <?php if( $bp_existed == 'true' ) { //check if bp existed ?>
    <?php bpbreadcrumbs(); ?>
    <?php } else { // if not bp detected..let go normal ?>
    <?php wpbreadcrumbs(); ?>
    <?php } ?>
    </div>

    4. In any css file you want add the following styles / adapt to be whatever you want:

    .breadcrumbs li {
    list-style-type: none;

    float: left;
    margin: 0 0.5em 0 0;
    }

    .breadcrumbs li:before {
    content: " » ";
    }

    .breadcrumbs .front_page:before {
    content: none;
    }

    Please bare in mind I've not tested this so just theorising you're going to have to adapt it a bit here probably.