Skip to:
Content
Pages
Categories
Search
Top
Bottom

wordpress breadcrumbs don't display the topics – help


  • nolimit966
    Participant

    @nolimit966

    Hi,

    Im using a bespoke WordPress theme for my site which ive created myself.

    Ive fully customized BBpress & put the theme inside my WP theme too.

    So far so good, it looks great & works fine too. But one problem is that the Breadcrumbs at the top of my page throughout the website only display:

    Home / Forum / HatWorks Forum

    If i then go into the GENERAL DISCUSSION SUB FORUM / TOPIC I get the following:

    Home / Forum / General Discussion

    Instead i should be getting:

    Home / Forum / HatWorks Forum / General Discussion

    If i then go to click a topic in general discussion I get:

    Home / Forum / Hello all forum members, what do you prefer?

    instead of

    Home / Forum / HatWorks Forum / General Discussion / Hello all forum members, what do you prefer?

    The current code I have written in my functions.php for the breadcrumbs is:

    <?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://hub.driveworks.co.uk/forums/forum/">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>';
                }
            }
    		
        }
       
    }
    
    ?>

    Any anyone help with the child navigation of this please?

    Thank you

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

  • Robkk
    Moderator

    @robkk

    id say look at the bbPress breadcrumbs code and copy that and add it to your custom breadcrumbs.

    its in bbpress>includes>common>

    then search breadcrumbs in an editor like notepad++


    nolimit966
    Participant

    @nolimit966

    thanks Rob, ill take a look at it now


    nolimit966
    Participant

    @nolimit966

    Ive taken a look at the template.php file to see what id need to implement into my current functions.php breadcrumbs class but im slightly confused.

    From my code above it looks like:
    $output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output; is only outputting a maximum of 3 ancestors. Is that correct?

    Php really is not my strong point.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar