The correct conditional you want to use for seeing if you’re on the front page is is_front_page(), then you can output different things. You could put this inside header.php itself to control the output. Then it doesn’t matter if you’re home page is the blog page, a page, a page with a custom template, or anything like that because it’ll always be the same header.php.
Thread Starter
vahn00
(@vahn00)
In the header.php I have to add it like this ?
<div class=”header <?php echo (is_page_template(‘page-slider.php’)) ? ‘has-slider’ : ” , echo (is_front_page (‘secondary-header.php’)) ?>”>
Thread Starter
vahn00
(@vahn00)
I have tried it and it doesn’t work, now a white stripe appears at the top of my page,
I’ve make backups and doesn’t disappear
What are you actually trying to achieve? A different class on the header?
The code you posted is incorrect PHP. You’re using is_front_page() incorrectly. It doesn’t take any arguments and you’ve put secondary-header.php. What is that for?
Also, you’ve got quotes in the wrong places and are trying to echo inside a ternary operator.
@vahn00,
1) First copy header.php and rename header-front.php.
2) front-page.php (using this file access site homepage code) – copy page.php and rename with this name.
3) edit – front-page.php and replace get_header() to get_header(‘front’)