Is Home Page Header?

Hello!

I need a little help if anyone is able to. I am currently working on re-building a site into WordPress and am struggling a little bit with Roots theme.

I’m a front-end developer, so HTML5, CSS3 and alike are all fine to me, but I’m trying to do something with PHP and I have no idea how to achieve it.

I’m trying to have a conditional statement so that I can hide the header and header-top-navbar on the front page (Which is a static page, not a posts page), but I simply can’t get my head around the conditional php statements to achieve this.

Would anyone be able to help me to achieve this?

Many thanks in advanced,

Jared

You’re going to need to get some basic PHP skills to work with Roots. Check out the CodeCademy course if you need the basics, then read through the tutorials on roots.io.

You’ll need a conditional statement for is_front_page, or a new base file for the home page.

Thanks for your help!

I’ve been taking a look at the conditional statements on that tutorials site, but I still can’t get my head around how to use “is_front_page” or how I create a new base file in roots. Any help would be greately appreciated.

Do you mean hide what’s in header-top-navbar.php? Hiding that will hide the site title/logo and navigation which is probably what you want.

You could do this by creating conditional statements, for example:

if(is_front_page()) {  // anything between the curly brakets will be outputted if this is the front page
    }

Basically we are using the is_front_page() function which comes from WordPress.

However in Roots I think the easiest way is to create a separate front page template in which you can exclude the top nav bar just for the front page. That is what I do anyway.

To do this, create a new file called base-front-page.php and copy over the code from base.php.

Then completely delete the following:

<?php
    do_action('get_header');
    // Use Bootstrap's navbar if enabled in config.php
    if (current_theme_supports('bootstrap-top-navbar')) {
      get_template_part('templates/header-top-navbar');
    } else {
      get_template_part('templates/header');
    }
  ?>

WordPress will use the code in base-front-page.php for your front page and you should now have no header.

Like @chriscarr says, it’s best to get some basic PHP skills so that you work with WordPress and Roots. However these things take time, and sometimes it can feel very difficult to take everything in.

Hope this helps.