Remove breadcrumbs if “home” in wordpress

2019-09-14 03:53发布

问题:

I have the breadcrumbs function in my header.php. I don't want to the breadcrumbs to appear on my homepage but all other pages I want it to appear. Please help in how I can achieve this.

The function to display the breadcrumbs in the header is:

<div id="breadcrumbs" class="container">
<div class="row">
    <?php breadcrumb_trail( array(
        'separator' => '&raquo;',
        'before' => '',
        'show_home' => '<img src="' . get_template_directory_uri() .    '/images/breadcrumb-home.png" />',
    ) ); ?>
</div>
</div>

回答1:

Ok i managed to solve this..

I replaced the body tag of my header with

<body<?php if(! is_home()) echo ' id="homepage"';?>>

and this to my css

body#homepage#breadcrumbs {visibility: hidden;}meaning that if the current page is the homepage, the breadcrumbs will not be shown.



标签: php wordpress