751 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • United States
CyberShot says

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?

356 posts
  • Exclusive Author
  • Has been a member for 2-3 years
  • Malaysia
  • Referred between 1 and 9 users
  • Sold between 10 000 and 50 000 dollars
billyf says

Hello,

Perhaps this diagram can help you in the template hierarchy : http://codex.wordpress.org/File:Template_Hierarchy.png

It 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).

751 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • United States
CyberShot says

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

158 posts
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Sold between 1 000 and 5 000 dollars
  • United States
greenshady says

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.

490 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says
If you looking for alway home page template. just add index.php and in page.php include index.php if it’s home page. if(is_front_page())
by
by
by
by
by
by