• 1.
    <?php
  • 2.
    /*
  • 3.
    Plugin Name: Simple Breadcrumb Navigation
  • 4.
    Plugin URI: http://www.kriesi.at/archives/wordpress-plugin-simple-breadcrumb-navigation
  • 5.
    Description: A simple and very lightweight breadcrumb navigation that covers nested pages and categories
  • 6.
    Version: 1
  • 7.
    Author: Christian "Kriesi" Budschedl
  • 8.
    Author URI: http://www.kriesi.at/
  • 9.
    */
  • 10.
     
  • 11.
    /*
  • 12.
    This program is free software; you can redistribute it and/or modify
  • 13.
    it under the terms of the GNU General Public License as published by
  • 14.
    the Free Software Foundation; either version 3 of the License, or
  • 15.
    (at your option) any later version.
  • 16.
     
  • 17.
    This program is distributed in the hope that it will be useful,
  • 18.
    but WITHOUT ANY WARRANTY; without even the implied warranty of
  • 19.
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  • 20.
    GNU General Public License for more details.
  • 21.
     
  • 22.
    You should have received a copy of the GNU General Public License
  • 23.
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  • 24.
    */
  • 25.
     
  • 26.
    class simple_breadcrumb {
  • 27.
        var $options;
  • 28.
        
  • 29.
        function simple_breadcrumb() {
  • 30.
                $this->options = array(//change this array if you want another output scheme
  • 31.
                'before' => '<span class="breadarrow"> ',
  • 32.
                'after' => ' </span>',
  • 33.
                'delimiter' => '&rarr;'
  • 34.
            );
  • 35.
            $markup = $this->options['before'] . $this->options['delimiter'] . $this->options['after'];
  • 36.
            global $post;
  • 37.
            echo '<p class="breadcrumbs"><a href="' . get_bloginfo('url') . '">';
  • 38.
            //bloginfo('name');
  • 39.
            esc_html_e('Home', 'udesign');
  • 40.
            echo "</a>";
  • 41.
            if (!is_front_page()) {
  • 42.
                echo $markup;
  • 43.
            }
  • 44.
            $output = $this->simple_breadcrumb_case($post);
  • 45.
            echo "<span class='current_crumb'>";
  • 46.
            if (is_page() || is_single()) {
  • 47.
                the_title();
  • 48.
            } else {
  • 49.
                echo $output;
  • 50.
            }
  • 51.
            echo " </span></p>";
  • 52.
        }
  • 53.
     
  • 54.
        function simple_breadcrumb_case($der_post) {
  • 55.
            global $post;
  • 56.
            $markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
  • 57.
            if (is_page()){
  • 58.
                if($der_post->post_parent) {
  • 59.
                    $my_query = get_post($der_post->post_parent);      
  • 60.
                    $this->simple_breadcrumb_case($my_query);
  • 61.
                    $link = '<a href="';
  • 62.
                    $link .= get_permalink($my_query->ID);
  • 63.
                    $link .= '">';
  • 64.
                    $link .= ''. get_the_title($my_query->ID) . '</a>'. $markup;
  • 65.
                    echo $link;
  • 66.
                }
  • 67.
                return;       
  • 68.
            }
  • 69.
            
  • 70.
            if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
  • 71.
     
  • 72.
                echo $seperator;
  • 73.
                echo 'The Events Calendar';
  • 74.
     
  • 75.
            } elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
  • 76.
        
  • 77.
                global $wp_query;
  • 78.
                $term_slug = $wp_query->query_vars['tribe_events_cat'];
  • 79.
                $term = get_term_by('slug', $term_slug, 'tribe_events_cat');
  • 80.
                get_term( $term_id, 'tribe_events_cat' );
  • 81.
                $name = $term->name;
  • 82.
                echo $seperator;
  • 83.
                echo '<a href="'.tribe_get_events_link().'">Events</a>';
  • 84.
                echo $seperator;
  • 85.
                echo $name;
  • 86.
        
  • 87.
            } elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List
  • 88.
        
  • 89.
                echo $seperator;
  • 90.
                echo 'Events List';
  • 91.
        
  • 92.
            } elseif( tribe_is_event() && is_single() ) { // Single Events
  • 93.
        
  • 94.
                echo $seperator;
  • 95.
                echo '<a href="'.tribe_get_events_link().'">Events</a>';
  • 96.
                echo $seperator;
  • 97.
                the_title();
  • 98.
        
  • 99.
            } elseif( tribe_is_day() ) { // Single Event Days
  • 100.
        
  • 101.
                global $wp_query;
  • 102.
                echo $seperator;
  • 103.
                echo '<a href="'.tribe_get_events_link().'">Events</a>';
  • 104.
                echo $seperator;
  • 105.
                echo 'Events on: ' . date('F j, Y', strtotime($wp_query->query_vars['eventDate']));
  • 106.
        
  • 107.
            } elseif( tribe_is_venue() ) { // Single Venues
  • 108.
        
  • 109.
                echo $seperator;
  • 110.
                echo '<a href="'.tribe_get_events_link().'">Events</a>';
  • 111.
                echo $seperator;
  • 112.
                the_title();
  • 113.
     
  • 114.
            } elseif(is_single()){
  • 115.
                $category = get_the_category();
  • 116.
                if (is_attachment()){
  • 117.
                    $my_query = get_post($der_post->post_parent);      
  • 118.
                    $category = get_the_category($my_query->ID);
  • 119.
                    if( $category != null ) {
  • 120.
                    $ID = $category[0]->cat_ID;
  • 121.
                    echo get_category_parents($ID, TRUE, $markup, FALSE );
  • 122.
                    }
  • 123.
                    previous_post_link("%link $markup");
  • 124.
     
  • 125.
                } elseif ( get_post_type( $post ) == 'post' ) {
  • 126.
                    $ID = $category[0]->cat_ID;
  • 127.
                    get_category_parents_for_breadcrumbs( $ID, TRUE, $markup, FALSE );
  • 128.
     
  • 129.
                } else { // custom types
  • 130.
                    echo ucwords( get_post_type( $post ) ) . $markup;
  • 131.
                }
  • 132.
                return;
  • 133.
            }
  • 134.
            if(is_category()){
  • 135.
                $category = get_the_category(); 
  • 136.
                $i = $category[0]->cat_ID;
  • 137.
                $parent = $category[0]-> category_parent;
  • 138.
     
  • 139.
                if($parent > 0 && $category[0]->cat_name == single_cat_title("", false)){
  • 140.
                    echo get_category_parents($parent, TRUE, $markup, FALSE);
  • 141.
                }
  • 142.
                return single_cat_title('',FALSE);
  • 143.
            }
  • 144.
            if (is_tax()) { // taxonomy
  • 145.
                $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  • 146.
                echo $term->name;
  • 147.
            }
  • 148.
            if(is_author()){
  • 149.
                $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
  • 150.
                return esc_html__('Author: ', 'udesign').$curauth->nickname;
  • 151.
            }
  • 152.
            if(is_tag()){ return esc_html__('Tag: ', 'udesign').single_tag_title('',FALSE); }
  • 153.
            if(is_404()){ return esc_html__('404 - Page not Found', 'udesign'); }
  • 154.
            if(is_search()){ return esc_html__('Search', 'udesign'); }
  • 155.
            if(is_year()){ return get_the_time('Y'); }
  • 156.
            if(is_month()){
  • 157.
                $k_year = get_the_time('Y');
  • 158.
                echo "<a href='".get_year_link($k_year)."'>".$k_year."</a>".$markup;
  • 159.
                return get_the_time('F');
  • 160.
            }
  • 161.
            if(is_day() || is_time()){
  • 162.
                $k_year = get_the_time('Y');
  • 163.
                $k_month = get_the_time('m');
  • 164.
                $k_month_display = get_the_time('F');
  • 165.
                echo "<a href='".get_year_link($k_year)."'>".$k_year."</a>".$markup;
  • 166.
                echo "<a href='".get_month_link($k_year, $k_month)."'>".$k_month_display."</a>".$markup;
  • 167.
                return get_the_time('jS (l)'); 
  • 168.
            }
  • 169.
        }
  • 170.
    }
<?php /* Plugin Name: Simple Breadcrumb Navigation Plugin URI: http://www.kriesi.at/archives/wordpress-plugin-simple-breadcrumb-navigation Description: A simple and very lightweight breadcrumb navigation that covers nested pages and categories Version: 1 Author: Christian "Kriesi" Budschedl Author URI: http://www.kriesi.at/ */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ 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' => '&rarr;' ); $markup = $this->options['before'] . $this->options['delimiter'] . $this->options['after']; global $post; echo '<p class="breadcrumbs"><a href="' . get_bloginfo('url') . '">'; //bloginfo('name'); esc_html_e('Home', 'udesign'); echo "</a>"; if (!is_front_page()) { echo $markup; } $output = $this->simple_breadcrumb_case($post); echo "<span class='current_crumb'>"; if (is_page() || is_single()) { 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( tribe_is_month() && !is_tax() ) { // The Main Calendar Page echo $seperator; echo 'The Events Calendar'; } elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages global $wp_query; $term_slug = $wp_query->query_vars['tribe_events_cat']; $term = get_term_by('slug', $term_slug, 'tribe_events_cat'); get_term( $term_id, 'tribe_events_cat' ); $name = $term->name; echo $seperator; echo '<a href="'.tribe_get_events_link().'">Events</a>'; echo $seperator; echo $name; } elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List echo $seperator; echo 'Events List'; } elseif( tribe_is_event() && is_single() ) { // Single Events echo $seperator; echo '<a href="'.tribe_get_events_link().'">Events</a>'; echo $seperator; the_title(); } elseif( tribe_is_day() ) { // Single Event Days global $wp_query; echo $seperator; echo '<a href="'.tribe_get_events_link().'">Events</a>'; echo $seperator; echo 'Events on: ' . date('F j, Y', strtotime($wp_query->query_vars['eventDate'])); } elseif( tribe_is_venue() ) { // Single Venues echo $seperator; echo '<a href="'.tribe_get_events_link().'">Events</a>'; echo $seperator; the_title(); } elseif(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 ); } else { // custom types echo ucwords( get_post_type( $post ) ) . $markup; } return; } 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_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); return esc_html__('Author: ', 'udesign').$curauth->nickname; } if(is_tag()){ return esc_html__('Tag: ', 'udesign').single_tag_title('',FALSE); } if(is_404()){ return esc_html__('404 - Page not Found', 'udesign'); } if(is_search()){ return esc_html__('Search', 'udesign'); } 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)'); } } }

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter