Closed JerresonJ closed 1 year ago
Hey @Jonathan-Garber. If you want to change the Template Resolution ordering you can do that with a plugin. Take a look at the example Blueprint code here:
The plugin adds a filter to the possibleTemplatesList
that is getting called just after we resolve the templates from the seedQuery. In that case we inspect the seedQuery object as documented here, and check if a specific template exists. If yes we can prepend a new template name that we use for routing. This is used to resolve the Project template for example.
In your case, you could create another plugin that checks if the templateName
exists and prepend a new template name for that route.
Let me know if this would cover your use-case.
Can this be included in the core of Faust... as opposed to a a plugin? I haven't tested it as a plugin yet but it seems to me the entire idea of seed querying is to know what template to use. Well we assigned the template in WP already so it should look for that matching template by default.
@Jonathan-Garber Thanks I will add a ticket to review since the templateName
can accept any type of string, we need to check how to encode this as well.
I was looking back through open issues and found someone else in Discord asking for this same functionality in a round-about way. We got it to work with a plugin, but it could be worth considering since custom page templates are technically are a part of the template hierarchy & block themes will make custom templates much easier to create: https://discord.com/channels/836253505944813629/1087807356206862346
Hey @Jonathan-Garber,
This is currently released in our nightly release, and should be out in an official Faust release soon.
If you'd like to test it/provide feedback, you can install the nightly release by running:
npm install @faustwp/core@canary
in your project.
From there, in the possible templates list, you should see the actual WordPress template as well.
Closing this one since its merged.
I am trying to specify the same template name for several pages in the WP Backend. So that I can create a single
wp-template
file in the front-end that is used for those specific pages. Thewp-template
file calls a general layout each page uses and goes from there.I may be misunderstanding something here but shouldn't the template assigned to the page be a 'possible template' on the front end?
Seed Query returns template data but this data seems to be ignored as 'possible templates'
So shouldn't I see something like
page-my-template
as a possible template to use here?Is there another way to specify a single wp-template file for a use like this or should we just skip this hierarchy here and use file based routes?
Leaning towards file based routing but I figured the idea of using the template designated as a possible template wouldn't hurt.