Archived topic
Breadcrumb
5 replies · Started by Roger on June 19, 2022
Hi!
How to decrease the font size of breadcrumbs? I'm not using Yoast.
I used a gain with the code below:`
<?php
function get_breadcrumb() {
echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
if ( is_category() || is_single() ){
echo " » ";
the_category (' • ');
if ( is_single() ) {
echo " » ";
the_title();
}
} elseif ( is_page() ) {
echo " » ";
echo the_title();
}
}
get_breadcrumb();
?>
Hi Roger,
To do as such, kindly alter your code into something like this:
<?php
function get_breadcrumb() {
echo '<div class="my-breadcrumbs">';
echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
if ( is_category() || is_single() ) {
echo ' » ';
the_category (' • ');
if ( is_single() ) {
echo ' » ';
the_title();
}
} elseif ( is_page() ) {
echo ' » ';
echo the_title();
}
echo '</div>';
}
get_breadcrumb();
?>
I added a div container with a class my-breadcrumbs which we can target through CSS.
Now, we can modify the font through a CSS like this which you may add in Appearance > Customize > Additional CSS:
.my-breadcrumbs {
font-size: 50px;
}
Hope this helps!
How to display only Home > Categories
You can modify your current code to something like this:
<?php
function get_breadcrumb() {
echo '<div class="my-breadcrumbs">';
echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
if ( is_category() || is_single() ) {
echo ' » ';
the_category (' • ');
}
echo '</div>';
}
get_breadcrumb();
?>
Kindly let us know how it goes.
Thank you!
You’re welcome Roger!