How to Show Content Only on The Home Page of WordPress Sites

If you are using your WordPress installation as a CMS for a website, you may well not be using the blog posts list as your landing page. In this case, you may want to have a page that displays content, such as a <div> only when that page is the landing page.

The key to this trick is simple and therefore, the explanation is equally simple.

First of all, you need to understand that the home page in WordPress-terms, refers to the blog posts index page. The page that you have chosen as your front page (Settings > Reading) is the front page and not the home page.

WordPress front page

The WordPress front page selection

Select the static page option then choose a front page from the drop menu. (This assumes that you have already created your static pages.) Depending on your page or content needs, open the page.php file and click where you need to add your unique content. Enter something like this:

    if ( is_front_page ( ) ) {
    echo ‘<div id=”front-panel”>’;
    echo “This is unique content that only appears here on the site front page”;
    echo ‘</div>’;

You can add ids and classes to your content as shown in the code above. For the blog posts index page, use is_home( ) instead.

other page

What do you think?

It's good to talk!

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