WordPress introduced a great feature in version 2.1: a static home page. Twas the feature that made WP a viable CMS. But unfortunately it broke the internal is_home() function. Here’s how to patch that.
The internal function is_home() will return true when the homepage is requested. But WordPress doesn’t take the static homepage into account, so in effect when you have a static homepage, this function will never return true.
This is a problem when you have a template named ‘home.php’ that must be loaded on the front page.
There are plugins to add some sort of is_homepage() functionality, and these work, but they still don’t solve the problem when you automagically want to load home.php. I have worked out an acceptable and futureproof fix to get this functionality back.
In my regular home.php template I have added a comment that makes it also a ‘custom template’:
<?php
/*
Template Name: Home
*/
?>
This little comment will show the home.php template as a custom template in WordPress. I selected it for the static homepage and bam! Works. And it’s futureproof! Because when they fix this bug the home template will be selected anyway. No need for plugins, no need to worry about upgrading. Yep, job well done.