breadcrumb.php 1.44 KB
<?php 
/**
 * Generate breadcrumbs
 * @author CodexWorld
 * @authorURL www.codexworld.com
 */


function get_breadcrumb() {
    global $post;
    echo '<a href="'.home_url().'" rel="nofollow">';
    _e('Home','msf');
    echo '</a>';
    echo '<span> / </span>';
        if (is_category() || is_single()) {
            the_category(' / ');
            if (is_single()) {
                echo '<span> / </span>';
                the_title();
            }
        } elseif (is_page()) {
            if($post->post_parent){
                $anc = get_post_ancestors( $post->ID );
                $title = get_the_title();
                foreach ( $anc as $ancestor ) {
                    $output = '<a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a> <span> / </span>';
                }
                echo $output;
                echo '<strong title="'.$title.'"> '.$title.'</strong>';
            } else {
                echo '<strong> '.get_the_title().'</strong>';
            }
        }
    elseif (is_tag()) {single_tag_title();}
    elseif (is_day()) {echo"Archive for "; the_time('F jS, Y');}
    elseif (is_month()) {echo"Archive for "; the_time('F, Y');}
    elseif (is_year()) {echo"Archive for "; the_time('Y');}
    elseif (is_author()) {echo"Author Archive";}
    elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "Blog Archives";}
    elseif (is_search()) {echo"Search Results";}
}