WordPress

Check If On Front Page In WordPress

In WordPress you can define a different page to be used as the front page for your blog. It doesn't have to be the index.php page it can be any page template used on your WordPress blog.

You can use a page template as the front page and any other page, but you might want to only display things on the front page of the blog and use the page template else where.

Here is a WordPress snippet to add code to the page template if it's being used as the front page.

if(is_front_page()) {
     // Enter code here
}
Back to top ^

Join Paulund

  • Access 100s of premium tutorials and downloadable content
  • Members content consists of premium WordPress plugins, CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
  • In-depth development tutorials
  • Priority tutorial requests
  • No ads

Join Paulund