To display content in WordPress only on the homepage (example.com) or on the index page (index.php), use the following code snippet:
<?php if ( is_front_page() ) : ?> <p>The content that is only shown on the homepage of your WordPress installation, or on the index.php page, but not on any other page or blogpost.</p> <?php endif ?>
2 thoughts on “WordPress: If homepage or index.php”
Thanks has been searching for this simple code.
Thank you, I seem to always lose this snippet =)