Created
March 5, 2015 08:58
-
-
Save designbuildtest/af405bd787ffd1309c3b to your computer and use it in GitHub Desktop.
Breadcrumbs - Modified/Big Brother theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Breadcrumbs @ https://wpcom-themes.svn.automattic.com/big-brother/functions.php | |
| */ | |
| function myplugin_breadcrumbs() { ?> | |
| <div class="breadcrumbs"> | |
| <?php | |
| $sep = '<span class="breadcrumbs-seperator">' . __( '»' ) . '</span>'; | |
| $before = '<span class="breadcrumbs-current">' . $sep ; | |
| $after = '</span>'; | |
| echo '<a class="breadcrumbs-home" href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Home' ) . '</a>'; | |
| if ( is_attachment() ) { | |
| global $post; | |
| if ( $post->post_parent ) { | |
| echo $sep . '<a class="breadcrumbs-ancestor" href="' . esc_url( get_permalink( $post->post_parent ) ) . '">' . get_the_title( $post->post_parent ) . '</a>' . $before . get_the_title() . $after; | |
| } | |
| else { | |
| echo $before . get_the_title() . $after; | |
| } | |
| } | |
| elseif ( is_page() ) { | |
| global $post; | |
| if ( $post->post_parent ) { | |
| $parent_id = $post->post_parent; | |
| $parent_links = array(); | |
| while ( $parent_id ) { | |
| $page = get_post( $parent_id ); | |
| $parent_links[] = $sep . '<a class="breadcrumbs-ancestor" href="' . esc_url( get_permalink( $page->ID ) ) . '">' . get_the_title( $page->ID ) . '</a>'; | |
| $parent_id = $page->post_parent; | |
| } | |
| echo implode( array_reverse( $parent_links ) ); | |
| } | |
| echo $before . get_the_title() . $after; | |
| } | |
| elseif ( is_search() ) { | |
| echo $before . sprintf( __( 'Search results for '%s'' ), get_search_query() ) . $after; | |
| } | |
| elseif ( is_404() ) { | |
| echo $before . __( 'Page not found' ) . $after; | |
| } | |
| ?> | |
| </div> | |
| <?php | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment