Answer the question
In order to leave comments, you need to log in
How to remove the link from the last element?
Breadcrumbs are displayed in the loop
Is it possible to somehow remove the link from the last element?
function add_crumb( ) {
$breadcrumbs = new WC_Breadcrumb();
echo '<a href="'. home_url() .'">Главная/</a>';
foreach ($breadcrumbs->generate() as $breadcrumb) {
echo '<a href="'. $breadcrumb[0] .'">' . $breadcrumb[0] . '/' . '</a>';
}
}
Answer the question
In order to leave comments, you need to log in
for example like this:
function add_crumb(){
$breadcrumbs = new WC_Breadcrumb();
$my_Array=$breadcrumbs->generate();
$num=count($my_Array);
$my_i=1;
echo '<a href="'. home_url() .'">Главная</a>/';
foreach ($my_Array as $breadcrumb) {
if($my_i!==$num){
echo '<a href="'. $breadcrumb[0] .'">' . $breadcrumb[0] . '</a>/';
}else{
echo $breadcrumb[0];
}
$my_i++;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question