WordPress Site Homepage HTML PHP

Displaying HTML (PHP) Only on WordPress Homepage

In the WordPress API and PHP programming language, this article introduces how to display additional HTML (PHP) only on the site's homepage.

Shou Arisaka
1 min read
Nov 18, 2025

In the WordPress API and PHP programming language, this article introduces how to display additional HTML (PHP) only on the site’s homepage.

The homepage looks like this:

Image

The second page of the homepage and archive pages should look like this:

Image

From an SEO perspective, having the same text on all post listing pages is not good for indexing.

Edit the theme’s index.php with rmate ../oceanwp/index.php.


if ( is_home() && ! is_paged() ){

echo <<<HTML

<p>something here</p>

HTML;

}

Place PHP like this wherever you like.

I put it below <div id=“content” class=“site-content clr”>.

The key is is_home() && ! is_paged(), but if you’ve set the post listing page as the homepage like I have (which is the default),

With just is_home(), it would include pages like https://yuis-programming.com/?paged=2 as well. For static pages, probably just is_home() would be fine.

Share this article

Shou Arisaka Nov 18, 2025

🔗 Copy Links