Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class simple_breadcrumb{
- var $options;
- function simple_breadcrumb(){
- $this->options = array( //change this array if you want another output scheme
- 'before' => '<span class="breadarrow"> ',
- 'after' => ' </span>',
- 'delimiter' => '→'
- );
- $markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
- global $post;
- echo '<p class="crumbs"><a href="'.get_bloginfo('url').'">';
- //bloginfo('name');
- esc_html_e('Home', 'mytheme');
- echo "</a>";
- if(!is_front_page()){echo $markup;};
- $output = $this->simple_breadcrumb_case($post);
- echo "<span class='current_crumb'>";
- if ( !is_front_page()) {
- the_title();
- }else{
- echo $output;
- }
- echo "</span></p> ";
- }
- function simple_breadcrumb_case($der_post){
- global $post;
- $markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
- if (is_page()){
- if($der_post->post_parent) {
- $my_query = get_post($der_post->post_parent);
- $this->simple_breadcrumb_case($my_query);
- $link = '<a href="';
- $link .= get_permalink($my_query->ID);
- $link .= '">';
- $link .= ''. get_the_title($my_query->ID) . '</a>'. $markup;
- echo $link;
- }
- return;
- }
- if(is_single()){
- $category = get_the_category();
- if (is_attachment()){
- $my_query = get_post($der_post->post_parent);
- $category = get_the_category($my_query->ID);
- if( $category != null ) {
- $ID = $category[0]->cat_ID;
- echo get_category_parents($ID, TRUE, $markup, FALSE );
- }
- previous_post_link("%link $markup");
- } elseif ( get_post_type( $post ) == 'post' ) {
- $ID = $category[0]->cat_ID;
- get_category_parents_for_breadcrumbs( $ID, TRUE, $markup, FALSE );
- $type = get_post_type($post->ID);
- if( $type == 'Portfolio') {
- echo '<a href="' . 'http://www.mysite.com/web-portfolio' . '">' . 'Portfolio' . '</a>' .$markup;
- } else if( $type == 'Artwork')
- echo '<a href="' . 'http://www.mysite.com/art-portfolio' . '">' . 'Artwork' . '</a>' .$markup;
- }
- }
- if(is_category()){
- $category = get_the_category();
- $i = $category[0]->cat_ID;
- $parent = $category[0]-> category_parent;
- if($parent > 0 && $category[0]->cat_name == single_cat_title("", false)){
- echo get_category_parents($parent, TRUE, $markup, FALSE);
- }
- return single_cat_title('',FALSE);
- }
- if (is_tax()) { // taxonomy
- $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
- echo $term->name;
- }
- if(is_author()){
- $curauth = get_userdatabylogin(get_query_var('author_name'));
- return esc_html__('Author: ', 'mytheme').$curauth->nickname;
- }
- if(is_tag()){ return esc_html__('Tag: ', 'mytheme').single_tag_title('',FALSE); }
- if(is_404()){ return esc_html__('404 - Page not Found', 'mytheme'); }
- if(is_search()){ return esc_html__('Search', 'mytheme'); }
- if(is_year()){ return get_the_time('Y'); }
- if(is_month()){
- $k_year = get_the_time('Y');
- echo "<a href='".get_year_link($k_year)."'>".$k_year."</a>".$markup;
- return get_the_time('F'); }
- if(is_day() || is_time()){
- $k_year = get_the_time('Y');
- $k_month = get_the_time('m');
- $k_month_display = get_the_time('F');
- echo "<a href='".get_year_link($k_year)."'>".$k_year."</a>".$markup;
- echo "<a href='".get_month_link($k_year, $k_month)."'>".$k_month_display."</a>".$markup;
- return get_the_time('jS (l)'); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement