Nova
WordPress Integration
Template Configuration

Template Configuration

Example Configuration

{
	"author": {
		"*": "template-author-archive"
	},
	"category": {
		"*": {
			"*": "template-term-archive",
			"1": "template-section-front"
		}
	},
	"post_type_archive": {
		"*": "template-archive",
		"pmc_top_video": "template-video-archive"
	},
	"tag": {
		"*": "template-term-archive"
	},
	"tax": {
		"*": "template-term-archive",
		"vcategory": {
			"*": "template-video-category-archive"
		}
	},
	"home": {
		"*": {
			"*": "template-archive",
			"1": "template-homepage"
		}
	},
	"index": {
		"*": "template-archive"
	},
	"page": {
		"*" : "template-page",
		"page-results": "template-search-archive"
	},
	"single": {
		"pmc-hub": "template-hub",
		"pmc-nova-homepage": "template-homepage",
		"pmc_top_video": "template-video",
		"*": "template-article"
	},
	"404": {
		"*": "template-404"
	}
}

Structure

  • Each top-level key in the configuration maps to a query type supported by the WordPress template loader.
  • Within each key is an object that maps specific query results to Nova components, along with a wildcard that's used for any context not otherwise provided for.
  • Within any configuration that corresponds to a paged view, separate components can be specified for specific page numbers, along with a wildcard entry for all other pages.

Example: single component for entire query type

In this example, all author archives use the <TemplateAuthorArchive /> component:

{
	"author": {
		"*": "template-author-archive"
	}
}

Example: components for specific post types

In this example, certain post types have their own components, with all others using a common component (<TemplateArticle />):

{
	"single": {
		"pmc-hub": "template-hub",
		"pmc-nova-homepage": "template-homepage",
		"pmc_top_video": "template-video",
		"*": "template-article"
	}
}

Each key under the single key corresponds to a post-type slug.

Example: components for different pages of a paged view

In this example, the first page of a paged view uses a different component than all subsequent pages:

{
	"category": {
		"*": {
			"*": "template-term-archive",
			"1": "template-section-front"
		}
	},
	"home": {
		"*": {
			"*": "template-archive",
			"1": "template-homepage"
		}
	}
}

While uncommon, it is possible to specify page numbers greater than 1 if there was a legitimate use case for doing so. For instance, page 10 could use some other component.

Unsupported Query Types

Some query types are not supported for one of the following reasons:

  • WordPress provides them, but PMC does not use them (post embeds are one example).
  • The query type is not for a request that is not user-facing or it is served by a plugin that provides a highly-specialized template. XML feeds, such as RSS and sitemaps, are examples of this.

For these query types, pmc-nova does not intercept the request, instead letting WordPress handle it as it normally would.

If, for some reason, a supported query type was to be handled outside of Nova, the relevant plugin would hook into the appropriate {$type}_template filter at a priority greater than that denoted in \PMC\Nova\Templating\Template_Interceptor::OVERRIDE_PRIORITY.