Reputation:
I found this one Remove breadcrumbs if "home" in wordpress but sadly not working for me
<body<?php if(! is_home()) echo ' id="homepage"';?>>
in header.php
body#homepage#breadcrumbs {visibility: hidden;}
and added in style.css
Upvotes: 0
Views: 7428
Reputation: 7793
CSS Update - it's .breadcrumbs
not #breadcrumbs
:
body#homepage .breadcrumbs { visibility: hidden; }
PHP:
<body<?php if(is_home()) echo ' id="homepage"';?>>
In your header.php code, the !
means NOT, therefore you're saying:
if NOT homepage, add id "homepage"
Which is the opposite of what you want.
Also note that visibility:hidden
will hide the element but preserve its space in the layout.. if you want to hide the element and its space you can use display:none
instead.
As @Eric-Mitijans explained, you have to add a space between body#homepage
and #breadcrumbs
otherwise you'd target a body tag with 2 IDs which is incorrect syntax.
Upvotes: 0
Reputation: 3741
First change your css to this. Because Breadcrumb Trail uses a class of breadcrumbs and not an id.
body#homepage .breadcrumbs
Have you tried using is_frontpage()
instead of is_home()
?
Do you realize that at the moment you are adding homepage id to all pages which are not the "home" page? Don't use the !
in your if.
<body<?php if(is_frontpage()) echo ' id="homepage"';?>>
blog postspage = frontpage
On the site front page:
Upvotes: 2
Reputation: 5284
There is another way to do it using body_class()
<body <?php body_class(); ?>>
And then in the css if it's home page you can use
body.home #breadcrumbs { visibility: hidden; }
Upvotes: 1
Reputation: 2179
Also, the body has .home class in Wordpress by default.
So you can achieve it without the PHP part.
body.home #breadcrumbs{display:none;}
Upvotes: 1
Reputation: 2179
Try separating the #breadcrumbs.
In the CSS:
body#homepage #breadcrumbs {visibility: hidden;}
The code you posted refers to a body element with an ID breadcrumbs. What you need to target is an element with #breadcrumbs ID, that is inside a body with #homepage ID.
Upvotes: 1