0

I experience an error with my breadcrumbs. I create it to get the homepage>the_archive_title>the_post_title doesn't always show the name of the archive title .. and when I changed in the $title variable in get_archive_title() function to be $title = __(get_the_title()); it fetches the name of archive surely only just in the page of archive, but when I got to page of post it shows
Home>post_title>post_title

So can any one helps me to fix it to show this format

Home > The Archive Title > the post Name

my breadcrumbs code

<h1><?php echo get_the_title() ?></h1>
<div class="breadcrumb">
    <a href="<?php echo get_home_url(); ?>">Home</a>
    <?php if (is_archive()) { ?>
        <a href="<?php echo the_permalink(); ?>"><?php echo get_the_archive_title(); ?></a>
    <?php } else { ?>
        <a href="<?php echo the_permalink(); ?>"><?php echo get_the_archive_title(); ?></a>
        <a href="#"><?php echo get_the_title(); ?></a>

    <?php } ?>
</div>
Constantine
  • 650
  • 9
  • 15
  • Breadcrumbs can be riddled with issues creating them yourself. Have you considered installing Yoast SEO which has a built in breadcrumb function? – Djave Nov 18 '21 at 11:49
  • @Djave im not usually using any plugins , i do it always by myself , i got this now but the function of get_the_archive_title() worked only on archive page , but when i go to the single page it's dosen't work ! – Yusuf ElNu'man Nov 21 '21 at 07:59

0 Answers0