Skip to content

Instantly share code, notes, and snippets.

@tawhidulIKhan
Created June 7, 2018 20:17
Show Gist options
  • Save tawhidulIKhan/799bfacb69288336a9980653fb7920b4 to your computer and use it in GitHub Desktop.
Save tawhidulIKhan/799bfacb69288336a9980653fb7920b4 to your computer and use it in GitHub Desktop.
function theme_breadcrumb(){
?>
<?php $page_object = get_queried_object(); ?>
<section class="pt-5 pb-5 bg-info breadcrumb-section">
<div class="container text-center">
<div class="row">
<div class="col-12">
<?php if (is_page()): ?>
<h1><?php the_title(); ?></h1>
<?php elseif(is_home()): ?>
<h1><?php esc_html_e( "Blog", 'sttrappress' ); ?></h1>
<?php elseif(is_archive()): ?>
<h1><?php esc_html_e( "Archive", 'sttrappress' ); ?></h1>
<?php elseif(is_single()): ?>
<h1><?php esc_html_e( "Blog", 'sttrappress' ); ?></h1>
<?php endif ?>
</div>
<div class="col-12">
<nav aria-label="breadcrumb" class="d-inline-block">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<?php bloginfo( 'url' ); ?>"><?php esc_html_e('Home','sttrappress'); ?></a></li>
<?php if (is_home()): ?>
<li class="breadcrumb-item"><?php esc_html_e('Blog','sttrappress'); ?></li>
<?php elseif(is_category()): ?>
<li class="breadcrumb-item"><?php echo esc_html($page_object->cat_name); ?></li>
<?php elseif(is_single()): ?>
<li class="breadcrumb-item"><?php echo esc_html($page_object->post_name); ?></li>
<?php elseif(is_archive()): ?>
<?php if (is_day()): ?>
<li class="breadcrumb-item"><?php printf(__('%s','textdomain'),get_the_date()); ?></li>
<?php elseif ( is_month() ): ?>
<li class="breadcrumb-item"><?php printf(__('%s','textdomain'),get_the_date('F Y')); ?></li>
<?php elseif ( is_year() ): ?>
<li class="breadcrumb-item"><?php printf(__('%s','textdomain'),get_the_date('Y')); ?></li>
<?php else: ?>
<li class="breadcrumb-item"><?php esc_html_e('Blog Archive','textdomain'); ?></li>
<?php endif ?>
<?php endif ?>
</ol>
</nav>
</div>
</div>
</div>
</section>
<?php
}
add_action( "breadcrumb", "theme_breadcrumb" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment