If post type = forum then breadcrumbs Home > Forums

I have an issue with breadcrumbs working with bbpress forums on my website. I have tried a few different ways to overcome this I think a simple solution would be something which states if the post type = forum then the breadcrumbs for that page should be Home > forum.

I have tried to integrate this within my breadcrumb functions php snippet with no joy, can anyone give me a pointer of what im doing wrong?

    ?php
function the_breadcrumb() {
    global $post;
    $post_type = $post-post_type;
    echo 'ul id="breadcrumbs"';
    if (!is_home()) {
        echo 'lia href="';
        echo get_option('home');
        echo '"';
        echo 'i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"/i Home';
        echo '/a/lili class="separator" / /li';
        if (is_category() || is_single()) {
            echo 'li';
            the_category(' /lili class="separator" / /lili ');
            if (is_single()) {
                echo '/lili class="separator" / /lili';
                the_title();
                echo '/li';
            }
        } elseif (is_page()) {
            if($post-post_parent){
                $anc = get_post_ancestors( $post-ID );
                $title = get_the_title();
                foreach ( $anc as $ancestor ) {
                    $output = 'lia href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'"'.get_the_title($ancestor).'/a/li li class="separator"//li'.$output;
                }
                echo $output;
                echo 'span title="'.$title.'" '.$title.'/span';
            } else {
                echo 'lispan '.get_the_title().'/span/li';
            }
        }
    }
    elseif (is_tag()) {single_tag_title();}
    elseif (is_day()) {echo"liArchive for "; the_time('F jS, Y'); echo'/li';}
    elseif (is_month()) {echo"liArchive for "; the_time('F, Y'); echo'/li';}
    elseif (is_year()) {echo"liArchive for "; the_time('Y'); echo'/li';}
    elseif (is_author()) {echo"liAuthor Archive"; echo'/li';}
    elseif (isset($_GET['paged'])  !empty($_GET['paged'])) {echo "liBlog Archives"; echo'/li';}
    elseif (is_search()) {echo"liSearch Results"; echo'/li';}
    elseif (is_post_type('forum')  is_post_type('post')  is_post_type('topic')  is_post_type('reply')){
echo"liFORUM BREADCRUMBS"; echo'/li';
}
    echo '/ul';
}
?

Thank you

Topic breadcrumb bbpress forum Wordpress

Category Web


I managed to fix this by:

<?php
function the_breadcrumb() {
    global $post;
    $post_type = $post->post_type;
    echo '<ul id="breadcrumbs">';
    if(get_post_type() == 'forum' OR get_post_type() == 'topic' OR get_post_type() == 'reply') {

      echo '<li><a href="';
        echo get_option('home');
        echo '">';
        echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
        echo '</a></li><li class="separator"> / </li>';
        echo '<a href="https://link">Forum</a>';
        echo ' &nbsp;/&nbsp; ';
        echo  the_title();

    }

    elseif (!is_home()) {
        echo '<li><a href="';
        echo get_option('home');
        echo '">';
        echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
        echo '</a></li><li class="separator"> / </li>';
        if (is_category() || is_single()) {
            echo '<li>';
            the_category(' </li><li class="separator"> / </li><li> ');
            if (is_single()) {
                echo '</li><li class="separator"> / </li><li>';
                the_title();
                echo '</li>';
            }
        } 

        elseif (is_page()) {
            if($post->post_parent){
                $anc = get_post_ancestors( $post->ID );
                $title = get_the_title();
                foreach ( $anc as $ancestor ) {
                    $output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output;
                }
                echo $output;
                echo '<span title="'.$title.'"> '.$title.'</span>';
            } else {
                echo '<li><span> '.get_the_title().'</span></li>';
            }
        }

    }

}

?>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.