
La mayor parate de los breadcrumb que había analizado antes de llevar a cabo el proyecto toscano.es eran básicamente el mismo:
¿No sabes lo que es un breadcrumb?, pues sería algo así como las migajas que dejaba Pulgarcito para no perderse cuando se internaba en tierras desconocidas. Esto, aplicado a un blog sería cualquier tipo de guía de navegación que oriente al lector para que sepa en todo momento donde se encuentra.
Ver original en Ayuda WordPress: Añadiendo Breadcrumb a tu plantilla
http://ayudawordpress.com/anadiendo-breadcumb-a-tu-plantilla/
Al ahondar un poco más en las cuestión, me dí cuenta de que este breadcrumb tenía muchas carencias y era mejor crear una funcion propia, sobretodo, para mostrar respuestas reales en paginas de busqueda, etiquetas, hijas…
A partir de articulos como:
- http://www.webcitizenmag.com/2010/05/20/how-to-get-top-parent-page-id-in-wordpress/
- http://bavotasan.com/2011/is_child-conditional-function-for-wordpress/
He creado un breadcrumb algo más complejo que nos permite ubicar al usuario correctamente.
Wordpress complex breadcrumb (1,3 KiB, 369 hits)

Lo primero que tenemos que hacer es incluir el siguiente codigo en functions.php
</pre>
/* PONEMOS LA PAGINA TOP EN BREADCRUMB */
function wp_breadcrumb() {
global $cat,$s,$post,$wp_locale;
if ( get_the_category() ) $category = get_the_category();
if ( is_tag() ) $tag = get_term($tag_ID, 'post_tag', OBJECT, 'display');
if ( is_author() ) $userdata = get_userdata($author);
}
function get_top_parent_page_id() {
global $post;
// Check if page is a child page (any level)
if ($post->ancestors) {
// Grab the ID of top-level page from the tree
return end($post->ancestors);
} else {
// Page is the top level, so use it's own id
return $post->ID;
}
}
/* Funcion de las hijas breadcrumb */
function is_child($page_id_or_slug) {
global $post;
if(!is_int($page_id_or_slug)) {
$page = get_page_by_path($page_id_or_slug);
$page_id_or_slug = $page->ID;
}
if(is_page() && $post->post_parent == $page_id_or_slug ) {
return true;
$parent_page = get_top_parent_page_id($post->ID);
$current = $post->ID;
$parent = $post->post_parent;
$grandparent_get = get_post($parent);
$grandparent = $grandparent_get->post_parent;
if ($root_parent = get_the_title($grandparent) !== $root_parent = get_the_title($current)) {
echo get_the_title($grandparent);
echo (' » '); } else {
echo get_the_title($parent);
echo (' » '); }
} else {
return false;
}
}
<pre>
Luego, vamos a añadir en la hoja de estilos la clase correspondiente, y la tuneamos, yo tengo algo tan simple como:
#breadcrumb{background:none; margin:0; padding:5px; border:none; clear:both;}
#breadcrumb a { text-decoration:none}

Por último creamos el archivo breadcrumb.php (luego solo habrá que hacer el include donde queramos que aparezca -lo típico es llamarlo en el header-). El código es:
</pre>
<div id="breadcrumb">
<strong><?php _e("Navigation", "your_theme"); ?></strong> :
<a href="<?php echo bloginfo('siteurl'); ?>" rel="bookmark" title="<?php echo bloginfo('name'); ?>"><?php _e('Home','your_theme'); ?></a>
<?php if ( $post->post_parent ) { echo (' » '); } ?>
<?php if ( is_category() || is_single() ) : echo (' » '); endif; ?>
<?php if ( is_category() ) { ?>
<?php echo substr(get_category_parents($cat,true,' » '),0,-9); ?> <?php } ?>
<?php if (is_tag() ) : ?><?php _e('Tags','your_theme'); ?>: <?php single_tag_title(); ?> <?php endif; ?>
<?php if (is_single() ) : ?> <?php the_category(' · ', 'multiple') ?> <?php echo (' » '); ?>
<?php endif; ?>
<?php if ( is_page() ) {if ( $post->post_parent ) {?>
<a href="<?php echo get_permalink($post->post_parent); ?>"><?php echo get_the_title($post->post_parent); ?></a><?php } ?>
<?php echo (' » '); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><?php } ?>
<?php if (is_404()){ _e('Error 404
','your_theme'); }
elseif (is_search()){ _e('Search results','your_theme'); }
elseif (is_single() ) { the_title(); }
else { } ?>
<?php if(is_home () ){ echo (' » '); echo bloginfo('name'); } ?>
<?php if (is_search() ) : ?> » <?php the_search_query(); ?> <?php endif; ?>
</div>
<pre>













