Best practices for file names in Wordpress

Hello everyone, I’ve read the Short guide to naming WordPress templates but I guess I didn’t quite understand the best practices for my specific situation.

I’d like to build a website with a home (static) page and a separate page for the blog posts, like this:

  • my_domain_name.com/ goes to a static home page
  • my_domain_name.com/blog goes to the blog page, with the main loop.

I have exported the static page as index.php and the blog page as front-page.php. Wordpress shows the blog page but ignores the static home page I’ve created.

How should I export these files so that WP understands the behavior I’m looking for?

Thanks in advance!

@Dimitri85 You need to make sure that you’ve named your templates correctly.

see this entry in the documentation.

Did you set the homepage as a static page in WP Settings > Reading? See https://pinegrow.com/docs/wordpress/a-guide-to-wordpress-templates-for-posts-pages-and-custom-post-types/

Now I did. That’s what I’ve done:

  1. Created 2 pages on WP admin: Home and Blog.
  2. In WP Setting > Reading, I pointed the home do Home and the posts page to Blog.
  3. The posts page I exported on Pinegrow as home.php.
  4. The static home page I exported both as front-page.php and index.php.

It’s working. When I point to / it shows the static page I wanted and when I point to /blog it shows the posts page. However, I don’t really know which .php file the WP is using to render the static home page.

It doesn’t sound right to have both front-page.php and index.php with the same content.

@Dimitri85 You don’t need to export the static homepage as front-page.php and index.php. WordPress will look for front-page.php first, but if you don’t export as front-page.php, it will use index.php, so either will work. Which one you use depends on whether the static page is unique among all the site pages (for example, having an unusual header), in which case I’d assign it to front-page.php. Because index.php is the fallback template for all pages, you wouldn’t want to assign an odd-looking page to it.