Call: (209) 560-6611

Display div only on home page, WordPress

Date: February 26, 2013 Author: ang Category: Tutorials Websites WordPress Tags: , Comments: 0

In this tutorial, I will show you how to display a div tag on the homepage of your WordPress website or blog.

  1. First you will need to edit the 'Header.php' file of your WordPress website. For instruction on how to edit your Header.php file using WordPress click here.
  2. Inside your header.php filemarkup section, enter the code:

     PHP |  copy code |? 
    1
    2
    <? if (is_home()){ ?>
    3
    <div>
    4
    Hello World
    5
    </div>
    6
    <? } ?>
    7
  3. Save your changes.

The 'is_home()' function is a built in WordPress function that checks if the visitor is on the homepage or not. This script will echo 'Hello world' only if the visitor is on the home page.

Leave a Reply

Your email address will not be published. Required fields are marked *

Before you post, please prove you are sentient.

What do bees make?

Before you post, please prove you are sentient.

What is 4 * 8?