Skip to content

Instantly share code, notes, and snippets.

@Elvinz
Forked from tinotriste/breadcrumbs-functions.php
Created September 12, 2023 03:09
Show Gist options
  • Select an option

  • Save Elvinz/bf2f1b95b824127a4f503d274eed6d0f to your computer and use it in GitHub Desktop.

Select an option

Save Elvinz/bf2f1b95b824127a4f503d274eed6d0f to your computer and use it in GitHub Desktop.

Revisions

  1. @tinotriste tinotriste revised this gist Sep 30, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion breadcrumbs-functions.php
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,7 @@ function the_breadcrumb() {
    global $post;
    $page_for_posts_id = get_option('page_for_posts');
    if ( $page_for_posts_id ) {
    $post = get_page($page_for_posts_id);
    $post = get_post($page_for_posts_id);
    setup_postdata($post);
    the_title();
    rewind_posts();
  2. @tinotriste tinotriste revised this gist Apr 15, 2013. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion breadcrumbs-functions.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    <?php
    // Breadcrumbs function - to include in functions.php
    /*=============================================
    = BREADCRUMBS =
    =============================================*/

    // to include in functions.php
    function the_breadcrumb() {

    $sep = ' > ';
  3. @tinotriste tinotriste revised this gist Apr 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion breadcrumbs-functions.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    <?php
    // Breadcrumbs function
    // Breadcrumbs function - to include in functions.php
    function the_breadcrumb() {

    $sep = ' > ';
  4. @tinotriste tinotriste created this gist Apr 15, 2013.
    61 changes: 61 additions & 0 deletions breadcrumbs-functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    <?php
    // Breadcrumbs function
    function the_breadcrumb() {

    $sep = ' > ';

    if (!is_front_page()) {

    // Start the breadcrumb with a link to your homepage
    echo '<div class="breadcrumbs">';
    echo '<a href="';
    echo get_option('home');
    echo '">';
    bloginfo('name');
    echo '</a>' . $sep;

    // Check if the current page is a category, an archive or a single page. If so show the category or archive name.
    if (is_category() || is_single() ){
    the_category('title_li=');
    } elseif (is_archive() || is_single()){
    if ( is_day() ) {
    printf( __( '%s', 'text_domain' ), get_the_date() );
    } elseif ( is_month() ) {
    printf( __( '%s', 'text_domain' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'text_domain' ) ) );
    } elseif ( is_year() ) {
    printf( __( '%s', 'text_domain' ), get_the_date( _x( 'Y', 'yearly archives date format', 'text_domain' ) ) );
    } else {
    _e( 'Blog Archives', 'text_domain' );
    }
    }

    // If the current page is a single post, show its title with the separator
    if (is_single()) {
    echo $sep;
    the_title();
    }

    // If the current page is a static page, show its title.
    if (is_page()) {
    echo the_title();
    }

    // if you have a static page assigned to be you posts list page. It will find the title of the static page and display it. i.e Home >> Blog
    if (is_home()){
    global $post;
    $page_for_posts_id = get_option('page_for_posts');
    if ( $page_for_posts_id ) {
    $post = get_page($page_for_posts_id);
    setup_postdata($post);
    the_title();
    rewind_posts();
    }
    }

    echo '</div>';
    }
    }
    /*
    * Credit: http://www.thatweblook.co.uk/blog/tutorials/tutorial-wordpress-breadcrumb-function/
    */
    ?>
    3 changes: 3 additions & 0 deletions calling-function.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    <!-- start breadcrumbs -->
    <?php the_breadcrumb(); ?>
    <!-- end breadcrumbs -->