Template files for Local SEO

If you’re using Local SEO with multiple locations, you get a new custom post type. In your WordPress Dashboard, it’s called Locations; 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. 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 often not ideal, in this aticle, we’ll explain how you can override this 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.

The /locations URL
Yoast SEO Breadcrumbs block, showing 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:

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, which removes most of the comment stuff etc that single.php normally holds.

Did this article answer your question?

Thanks for your feedback!

Related articles

Get free SEO tips!