I am working on a site. I made a file called home.php and put that into my theme. WordPress picks it up nicely. I wanted to use home.php so that you wouldn’t have to go through the steps of setting the static homepage and page template stuff. Also so that when the theme is activated, this page will show by default making it easier to set up. I made a template for the blog and set that for the blog page in reading and as the page template. Problem I found is that when I use home.php and then go to the blog page, home shows as the blog even though I have blog set up as a template. Is there a way to set a static homepage without having to set the templates?
Hello,
Perhaps this diagram can help you in the template hierarchy : http://codex.wordpress.org/File:Template_Hierarchy.pngIt seems that naming it to front-page.php is better than home.php (the former being more specific as it only shows up at the homepage, while the latter will show up at the blog posts index page as well).
yes but if you use front-page.php then you have to make a page called home, assign the template and then assign it again in the reading options. I don’t want to have to do that. The diagram does not help solve this issue
home.php is for the posts page. It is not to be used for any other purpose than to show the latest blog posts.
To do what you want though, you must use front-page.php. It will always overwrite what’s shown on the front page of the site regardless of reading settings. If you take this route, the user only has to go to Settings > Reading to create a blog page (i.e., the posts page) if they choose to have one.
Of course, this is usually not a good idea for public themes (it’s good for client themes though). The theme shouldn’t dictate what’s shown on the front of the site, which is the purpose of front-page.php. I’d go with a custom page template instead to give users more flexibility. Yeah, it means more steps, but I’ve never had a user complain in the past 5 years of doing it this way.
if(is_front_page())