<?php // Inicializar variables $home_url = home_url('/'); $home_text = 'Inicio'; $breadcrumbs_html = ''; // Obtener información de la página actual $current_page = get_queried_object(); $current_page_title = $current_page->post_title; $current_page_url = get_permalink($current_page->ID); // Añadir enlace a la página de inicio $breadcrumbs_html .= '<a href="' . $home_url . '">' . $home_text . '</a> > '; // Añadir enlaces para páginas anteriores if (is_single()) { // Si es una publicación, añadir enlace a la categoría de la publicación $category = get_the_category($current_page->ID); $category_url = get_category_link($category[0]->cat_ID); $breadcrumbs_html .= '<a href="' . $category_url . '">' . $category[0]->cat_name . '</a> > '; } elseif (is_page()) { // Si es una página, añadir enlaces para todas las páginas anteriores $parent_id = $current_page->post_parent; while ($parent_id) { $page = get_page($parent_id); $breadcrumbs_html = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a> > ' . $breadcrumbs_html; $parent_id = $page->post_parent; } } // Añadir enlace a la página actual $breadcrumbs_html .= '<a href="' . $current_page_url . '">' . $current_page_title . '</a>'; // Devolver migas de pan como cadena de texto HTML echo '<div class="breadcrumbs">' . $breadcrumbs_html . '</div>'; ?>
01 – Blog (Single)
<?php global $post; // Obtén el ID del post actual $post_id = $post->ID; // Obtén el contenido del post $post_content = get_post_field( 'post_content', $post_id ); // Calcula el tiempo de lectura estimado en minutos $word_count = str_word_count( strip_tags( $post_content ) ); $reading_time = floor( $word_count / 200 ); // Muestra el tiempo de lectura estimado en minutos echo '<p class="read_time">Reading Time: ' . $reading_time . ' min.</p>'; ?>