Add WordPress Breadcrumbs


<?php $post_id = get_the_ID(); ?>
<?php if(!is_front_page() && !is_archive()){ ?>
<div class=”bread_cr”>
<span>
<a style=”color: #A8CE3F;” href=”<?php bloginfo(‘url’); ?>”>Home</a> » <?php echo get_the_title( $post_id ); ?>
</span>
</div>
<?php } else if(is_archive()) {
$obj = get_queried_object();
$parent = $obj->parent;
if($parent != 0){
global $wpdb;
$cat_name = $wpdb->get_var(“SELECT name FROM wp_terms WHERE term_id=’$parent'”);
$cat_slug = $wpdb->get_var(“SELECT slug FROM wp_terms WHERE term_id=’$parent'”);
}
?>
<div class=”bread_cr” style=”margin-bottom: 12px;”>
<span>
<a style=”color: #A8CE3F;” href=”<?php bloginfo(‘url’); ?>”>Home</a> »
<?php if($parent != 0){ ?>
<a href=”<?php bloginfo(‘url’); ?>/category/<?php echo $cat_slug; ?>”><?php echo $cat_name; ?></a> »
<?php } ?>
<?php echo $obj->name; ?> <br>
</span>
</div>
<?php } ?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s