How to set a custom post type in faustjs to find the corresponding page? #1308
Replies: 5 comments 1 reply
-
Hey. If your page does not resolve to valid template type, you may need to add a custom hook. See the example in Portfolio Blueprint: https://github.com/wpengine/atlas-blueprint-portfolio/blob/main/plugins/ProjectTemplatePlugin.js export class EventTemplatePlugin {
constructor() {}
apply(hooks) {
hooks.addFilter('possibleTemplatesList', 'faust', (templates, data) => {
if (data?.seedNode?.__typename === 'Event') {
return Array.from(new Set(['event', ...templates]));
}
return templates;
});
}
} |
Beta Was this translation helpful? Give feedback.
-
Behind the scenes Faust uses a seed query to try to find a valid template to use for each page: https://faustjs.org/docs/faustwp/seed-query In your example, if the path |
Beta Was this translation helpful? Give feedback.
-
I have the same problem. I'm using The Events Calendar which is registering a the post type and link path. I get a 404 and not sure how to get around this. |
Beta Was this translation helpful? Give feedback.
-
I had the same issue when I was testing Faust js, I have created a post type products changes the filename to [[single-product]].js once done restart the localhost hope this helps |
Beta Was this translation helpful? Give feedback.
-
To see the
This means that the seedQuery was able to resolve the page metadata. Then you need to create a template for the event CPT and export this in the index.js export default {
'front-page': frontPage,
page,
single,
event, // <<---- Event template
archive,
}; If you instead do not see any Possible templates list, then it means that the seedQuery for the |
Beta Was this translation helpful? Give feedback.
-
I custom post address is http://localhost/events/brain-organoids-training-course
When I visit in faustjs and the page returns 404, how do I solve this problem?
Beta Was this translation helpful? Give feedback.
All reactions