• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Gokul Deepak

GoCool and Debug

  • Home
  • WordPress
  • Android
  • How to
  • About Me
Home » Wordpress » Custom Breadcrumbs in Genesis Theme

Custom Breadcrumbs in Genesis Theme

January 3, 2017 by GokulDeepak Leave a Comment

Sometimes we have to customise the breadcrumbs for easy navigation and easy understandings. Here I have given the Breadcrums which I have used. Using this I have layered the Breadcrumbs like a Post under Page. I have used P2P plugin which connects Page to Post. You can simply edit that part and replace your own layer too.

Step 1: Copy and paste the below php code in your own blog custom plugin. If you haven’t created a custom plugin please make one fast.

If you are not interested to create a custom plugin simply paste this code in functions.php

 

//Custom Breadcrumbs
function the_breadcrumbs() {
 
        global $post;
 
        if (!is_home()) {
 
            echo "<a href='";
            echo get_option('home');
            echo "'>";
            echo "Lyrics";
            echo "</a>";
 
            if (is_category() || is_single()) {
 
                echo "  »  ";
                $cats = get_the_category( $post->ID );
 
                foreach ( $cats as $cat ){
                    echo $cat->cat_name;
                    echo "  »  ";
                }
               
                
                if (is_single()) {
                echo do_shortcode(' [p2p_connected type=posts_to_pages mode=inline]');
                echo "  »  ";
                    the_title();
                }
            } elseif (is_page()) {
 
                if($post->post_parent){
                    $anc = get_post_ancestors( $post->ID );
                    $anc_link = get_page_link( $post->post_parent );
 
                    foreach ( $anc as $ancestor ) {
                        $output = "  »  <a href=".$anc_link.">".get_the_title($ancestor)."</a>  »  ";
                    }
 
                    echo $output;
                    the_title();
 
                } else {
                    echo '  »  ';
                    echo the_title();
                }
            }
        }
    elseif (is_tag()) {single_tag_title();}
    elseif (is_day()) {echo"Archive: "; the_time('F jS, Y'); echo'</li>';}
    elseif (is_month()) {echo"Archive: "; the_time('F, Y'); echo'</li>';}
    elseif (is_year()) {echo"Archive: "; the_time('Y'); echo'</li>';}
    elseif (is_author()) {echo"Author's archive: "; echo'</li>';}
    elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "Blogarchive: "; echo'';}
    elseif (is_search()) {echo"Search results: "; }
}
//End of Custom Breadcrumbs

 Step 2:

Now the function is ready and you simply have to call the function in where the breadcrums have to be displayed. In my case I have used Genesis Sample theme and so I have used Simple Genesis Hooks.

Paste the following code in genesis_before_entry hook.

<?php if(function_exists('the_breadcrumbs')) the_breadcrumbs(); ?>

Mission Completed.

Related

Filed Under: Wordpress Tagged With: Genesis, Genesis Sample Theme, Studiopress

Authored by Gokul Deepak S

Reader Interactions

Leave a Reply Cancel reply

Primary Sidebar

Popular Posts

  • How to find the date of the Facebook group it was created
  • Home
  • How to add ads.txt on Bluehost
  • Elementor Plugin and Nginx Configuration
  • Cloudflare SSL off vs Flexible Vs Full vs Full Strict
  • How to block access to the wp-content uploads folder
  • Output for timedatectl list-timezones

Recent Posts

  • Can’t connect to Ubuntu with SSH
  • Change Timezone in Ubuntu 20.04 – Simple method
  • Output for timedatectl list-timezones
  • PM2 Cheatsheet – Important Commands
  • MongoDB Terminal commands – Cheatsheet

Archives

Categories

  • Android
  • Apache
  • Blogger
  • Computer Tips
  • Earn
  • Facebook Tips
  • Git
  • Google Tips
  • How to
  • Laptop Tips
  • Laptops
  • Linux
  • Mobile
  • MongoDB
  • Nginx
  • Notepad++
  • PostgresQL
  • Ubuntu
  • Wordpress
  • Xenforo

Tags

Android Android One Bluehost Comparisions Custom ROM Elementor Facebook Genesis Genesis Sample Theme Google Drive How to Lineage OS OnePlus One OwnCloud Rooting Smartphones Stock ROM Studiopress Wordpress plugin

Copyright © 2021 · Maintained by GokulDeepak