Template files for Local SEO

If you’re using Local SEO with multiple locations, you get a new custom post type. It’s called “Locations” in the admin, but under the hood it’s called wpseo_locations. This post type creates two types of pages: a custom post type archive page and single location pages.

Because of how the WordPress template hierarchy works, in a “default” theme, the custom post type archive would use the file archive.php, and the single location file would use single.php. This is, in many cases, not ideal. So it’s a good thing you can override that behavior!

The Custom Post Type Archive

To have your theme not use the archive.php file, you can create a file called archive-wpseo_locations.php. This file will need to be entered into your theme directory.

You could use this page, for instance, to show a map of all your locations. All your locations are expected to be shown at the /locations url.


You can find a good example of what such a page should look like in this gist, based on the WordPress TwentyTwelve theme:

locations archive

The single location page

In the same way as you can create archive-wpseo_locations.php, you can also create single-wpseo_locations.php. The easiest fix here is often to just copy the page.php template into this file, that removes most of the comment stuff etc that single.php normally holds.