Title: Adding Breadcrumbs
Last modified: August 22, 2016

---

# Adding Breadcrumbs

 *  Resolved [redthruviolet](https://wordpress.org/support/users/redthruviolet/)
 * (@redthruviolet)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/)
 * GeneratePress:
 * Is there any way to add breadcrumbs in the theme?
 * :RedthruViolet

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Theme Author [Tom](https://wordpress.org/support/users/edge22/)
 * (@edge22)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196523)
 * Breadcrumbs aren’t built into the theme, but you can easily integrate breadcrumbs
   into it.
 * For example, WordPress SEO has a breadcrumbs feature, which you can add to the
   theme in two ways:
 * 1. The GP Hooks addon – simply paste the breadcrumbs PHP function into your desired
   hook (Before Content most likely), click execute PHP and you’re done.
 * 2. With a PHP function in a child theme. Which would look something like this:
   [https://gist.github.com/generatepress/a13fbd2bb88008da572f](https://gist.github.com/generatepress/a13fbd2bb88008da572f)
 * To get the breadcrumbs code, go to “SEO > Internal Links”, and you’ll find it
   at the bottom.
 * This same method can be used with any third-party breadcrumb plugin that offers
   PHP code.
 * Let me know if this helps or not,
    Tom
 *  Theme Author [Tom](https://wordpress.org/support/users/edge22/)
 * (@edge22)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196642)
 * Hi there,
 * Were you able to add the breadcrumbs to the theme?
 * Let me know 🙂
    Tom
 *  Thread Starter [redthruviolet](https://wordpress.org/support/users/redthruviolet/)
 * (@redthruviolet)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196643)
 * Yes, breadcrumbs have been added.
 * You can see them here:
 *  [http://www.sustainablemontereycounty.com/likeweebly/](http://www.sustainablemontereycounty.com/likeweebly/)
 * In the child theme header.php file, after “<?php do_action( ‘generate_after_header’);?
   >”, I put this code:
 *  <div class=”grid-container grid-parent”>
    <?php the_breadcrumb(); ?> </div>
 * Here is the breadcrumb code, which, unfortunately I had to place in the parent
   theme’s functions.php file (this seems to be the only outstanding issue):
 * function the_breadcrumb()
    { global $post;
 * /* Check for Front Page */
 *  if (is_front_page())
    { echo ‘<p id=”breadcrumbs”> You are Here:   <a href=”‘;
   echo get_option(‘home’); echo ‘”>**‘; echo ‘Home’; echo ‘ </p>’; }
 *  else
 *  {
 * /* Show Breadcrumbs */
 *  echo ‘<ul id=”breadcrumbs”>’;
 *  echo ‘
    -  You are Here:   <a href=”‘;
       echo get_option(‘home’); echo ‘”>’; echo ‘Home’;
      echo ‘
    -  <li class=”separator”> > ‘;
    -  if( is_home() && get_option(‘page_for_posts’) )
       { /* echo ‘[‘; */ echo ‘**‘.
      apply_filters(‘the_title’,get_page( get_option(‘page_for_posts’) )->post_title).‘**‘;/*
      echo ‘‘; */ }
    -  if (is_category() || is_single())
       { echo ‘
    - ‘;
       the_category(‘
    -  <li class=”separator”> >
    -  ‘);
    -  if (is_single())
       { echo ‘ <li class=”separator”> >
    - ‘;
       the_title(); echo ‘
    - ‘;
       } }
    -  elseif (is_page())
    -  {
    -  if($post->post_parent)
       { $anc = get_post_ancestors( $post->ID ); $anc_count
      = count($anc); // echo “ anc_count = ” . $anc_count;
    -  $title = get_the_title();
    - /* Go backwards through the array, to get the correct path display */
    -  for ($k=$anc_count; $k>0; $k=$k-1)
       { $ancestor = $anc[$k-1]; $output = ‘
    -  [‘.get_the_title($ancestor).’](https://wordpress.org/support/topic/adding-breadcrumbs-1/&apos;.get_permalink($ancestor).&apos;?output_format=md)
    -  <li class=”separator”> > ‘;
       echo $output;
    -  }
    -  echo ‘
    -  <strong title=”‘.$title.'”> ‘.$title. ‘
    - ‘;
       }
    -  else
    -  {
       echo ‘
    - ** ‘ .get_the_title(). ‘**
    - ‘;
       }
    -  }
    -  elseif (is_tag()) {single_tag_title();}
       elseif (is_day()) {echo”
    - Archive for “; the_time(‘F jS, Y’); echo’
    - ‘;}
       elseif (is_month()) {echo”
    - Archive for “; the_time(‘F, Y’); echo’
    - ‘;}
       elseif (is_year()) {echo”
    - Archive for “; the_time(‘Y’); echo’
    - ‘;}
       elseif (is_author()) {echo”
    - Author Archive”; echo’
    - ‘;}
       elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) {echo ”
    - Blog Archives”; echo’
    - ‘;}
       elseif (is_search()) {echo”
    - Search Results”; echo’
    - ‘;}
    -  echo ”;
    -  }
       }
 *  Theme Author [Tom](https://wordpress.org/support/users/edge22/)
 * (@edge22)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196644)
 * You can put that function in the child theme’s functions.php file instead of 
   the parent theme’s functions.php file – it will work the same.
 * Then you can hook it into the header instead of editing that file, like this:
 *     ```
       add_action('generate_after_header','custom_add_breadcrumbs');
       function custom_add_breadcrumbs() { ?>
            <div class="grid-container grid-parent">
                  <?php the_breadcrumb(); ?>
            </div>
       <?php }
       ```
   
 * That would also go in the child theme’s functions.php file.
 *  Thread Starter [redthruviolet](https://wordpress.org/support/users/redthruviolet/)
 * (@redthruviolet)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196647)
 * Well, I tried some of that.
    I copied functions.php to the child theme folder,
   and added the function there. Then, when I launched the site, there were error
   messages saying you cannot redeclare a function.
 *  Theme Author [Tom](https://wordpress.org/support/users/edge22/)
 * (@edge22)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196648)
 * The functions file should be empty except for your new function.
 * The whole file looks like this:
 *     ```
       <?php
       add_action('generate_after_header','custom_add_breadcrumbs');
       function custom_add_breadcrumbs() { ?>
            <div class="grid-container grid-parent">
                  <?php the_breadcrumb(); ?>
            </div>
       <?php }
   
       function the_breadcrumb()
       {
   
       ... The rest of the_breadcrumb function
   
       }
       ```
   
 * There’s no need to copy the functions over from the parent’s functions.php file–
   those functions are included anyways.
 *  Thread Starter [redthruviolet](https://wordpress.org/support/users/redthruviolet/)
 * (@redthruviolet)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196649)
 * Well, thank you so much!
    That worked.
 *  Theme Author [Tom](https://wordpress.org/support/users/edge22/)
 * (@edge22)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196650)
 * You’re very welcome.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Adding Breadcrumbs’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/generatepress/3.6.1/screenshot.
   png)
 * GeneratePress
 * [Support Threads](https://wordpress.org/support/theme/generatepress/)
 * [Active Topics](https://wordpress.org/support/theme/generatepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/generatepress/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/generatepress/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Tom](https://wordpress.org/support/users/edge22/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/adding-breadcrumbs-1/#post-5196650)
 * Status: resolved