Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Breadcrumbs */
- function get_breadcrumbs() {
- global $wp_query;
- if ( !is_home() ){
- echo '<div class="breadcrumb">';
- echo '<ul>';
- echo '<li><a href="'. get_option('home') .'">Início </a></li>';
- if ( is_category() ) {
- $catTitle = single_cat_title( "", false );
- $cat = get_cat_ID( $catTitle );
- echo "<li> <span> »</span> ". get_category_parents( $cat, TRUE, " <span>»</span> " ) ."</li>";
- }
- elseif ( is_archive() && !is_category() ) {
- echo "<li> <span> »</span> Archives</li>";
- }
- elseif ( is_search() ) {
- echo "<li> <span> »</span> Search Results</li>";
- }
- elseif ( is_404() ) {
- echo "<li> <span> »</span> 404 Not Found</li>";
- }
- elseif ( is_single() ) {
- $category = get_the_category();
- $category_id = get_cat_ID( $category[0]->cat_name );
- echo '<li> <span> »</span> '. get_category_parents( $category_id, TRUE, " <span>»</span> " );
- echo the_title('','', FALSE) ."</li>";
- }
- elseif ( is_page() ) {
- $post = $wp_query->get_queried_object();
- if ( $post->post_parent == 0 ){
- echo "<li> <span> »</span> ".the_title('','', FALSE)."</li>";
- } else {
- $title = the_title('','', FALSE);
- $ancestors = array_reverse( get_post_ancestors( $post->ID ) );
- array_push($ancestors, $post->ID);
- foreach ( $ancestors as $ancestor ){
- if( $ancestor != end($ancestors) ){
- echo '<li> <span> »</span> <a href="'. get_permalink($ancestor) .'">'. strip_tags( apply_filters( 'single_post_title', get_the_title( $ancestor ) ) ) .'</a></li>';
- } else {
- echo '<li> <span> »</span> '. strip_tags( apply_filters( 'single_post_title', get_the_title( $ancestor ) ) ) .'</li>';
- }
- }
- }
- }
- echo '</ul>';
- echo '</div>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment