1

I would like to display a div, only on the homepage. Is this possible?

I have a banner in the header.php file and only want to display this banner div on the homepage.

How could I achieve this?

Thanks in advance.

  • Downvoted for lack of research and effort. You should have received a ton of possible duplicates just below your question's title when you wrote this question, also, in the sidebar on the right are many possible duplicates. There is also, apart from that, so much info about this subject, I do not believe that you could not find any info if you actually tried searching for it – Pieter Goosen Jul 18 '16 at 10:32
  • Why is it people have to be so rude. It's a joke! – Jacob Punton Jul 18 '16 at 10:40
  • I'm not rude, I'm talking the truth here. We are all here in our spare time to help others. We are not here to spoonfeed people that does not even take the time and effort to help themselves. Sites like these are here to help you when everything you have tried failed. You are the joke here, not us – Pieter Goosen Jul 18 '16 at 10:43
1

Depending on your setup you could use the conditional is_home() or is_front_page() like this:

<?PHP if( is_home() ) { ?>

<div> … </div>

<?PHP } ?>

See also the question "When to use is_home() vs is_front_page()?" for further details on the defferences between the two… 

PS: you should consider using a child theme for this.

  • And this could work in the header.php file? – Jacob Punton Jul 18 '16 at 10:20
  • Yes, both work outside the loop – i just checked both inside header.php in a test environment… – tillinberlin Jul 18 '16 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.