Skip to content

Instantly share code, notes, and snippets.

@zourite
Created June 24, 2015 10:42
Show Gist options
  • Save zourite/22422f407cd5d8ec2deb to your computer and use it in GitHub Desktop.
Save zourite/22422f407cd5d8ec2deb to your computer and use it in GitHub Desktop.
Fil d'ariane pour #Wordpress
<?php function the_breadcrumb() {
global  $wp_query;
$name = single_cat_title ( '' '', false);
$category_id = get_cat_ID( $name );
$category = get_the_category();
$category_link = get_category_link( $category_id );
//Categorie Parents
$object = $wp_query->get_queried_object();
$parent_id  = $object->category_parent;
$categoryP  = get_category($parent_id);
$category_linkP = get_category_link( $parent_id );
echo '<a href="';
echo get_option('home');
echo '">';
echo 'Accueil';
echo '</a> &raquo; ';
if (is_category() )
if ($object->category_parent == 0) { ?>
<a href="<?php echo $category_link; ?>" title="<?php echo $name; ?>"><?php echo $name;  ?></a>
<?php
}
else{
?>;
<a href="<?php echo $category_linkP; ?>" title="<?php echo $categoryP->cat_name; ?>"><?php echo $categoryP->cat_name; ?></a> &raquo; <?php echo $name;  ?>
<?php
}
if (is_single()) {
$name = $category[0]->;cat_name;
$category_id = get_cat_ID( $name );
$category_link = get_category_link( $category_id );
?>
<a href="<?php echo $category_link; ?>" title="<?php $name ?>">>?php echo $name; ?></a>
<?php echo " &raquo; ";
the_title();
}
if (is_search()) {
echo the_search_query();
}
if (is_page()) {
echo the_title();
}
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment