Salutare. De curand am umblat un pic la blog pe partea de modul Seo in sensul ca am dezinstalat Yoast si am trecut la Rank Math SEO. Urmarind acest tutorial de setare a modulului am realizat ca tema mea nu are functie de BREADCRUMBS care ajuta pe partea de Seo.
Tot ce a trebuit sa fac este sa adaug urmatoarea functie in fisierul functions.php al temei:
function the_breadcrumb() {
$sep = ' > ';
if (!is_front_page()) {
echo '<div class="breadcrumbs">';
echo '<a href="';
echo get_option('home');
echo '" >';
bloginfo('name');
echo '</a>' . $sep;
if (is_category() || is_single() ){
the_category();
} elseif (is_archive() || is_single()){
if ( is_day() ) {
printf( __( '%s', 'text_domain' ), get_the_date() );
} elseif ( is_month() ) {
printf( __( '%s', 'text_domain' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'text_domain' ) ) );
} elseif ( is_year() ) {
printf( __( '%s', 'text_domain' ), get_the_date( _x( 'Y', 'yearly archives date format', 'text_domain' ) ) );
} else {
_e( 'Blog Archives', 'text_domain' );
}
}
if (is_single()) {
echo $sep;
the_title();
}
if (is_page()) {
echo the_title();
}
if (is_home()){
global $post;
$page_for_posts_id = get_option('page_for_posts');
if ( $page_for_posts_id ) {
$post = get_page($page_for_posts_id);
setup_postdata($post);
the_title();
rewind_posts();
}
}
echo '</div>';
}
}
Functia se apelea in single.php
the_breadcrumb();
Un pic de css pentru clasele din functie:
.breadcrumbs {
padding: 8px 15px;
margin-bottom: 20px;
list-style: none;
background-color: #ff;
border-radius: 4px;
display: flex;
}
.breadcrumbs a {
color: #78e08f;
text-decoration: none;
}
ul.post-categories {
display: flex;
}
ul.post-categories li{margin: 0 5px;}