breadcrumb.php
1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?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";}
}