How to set a custom post type in faustjs to find the corresponding page? #1308
Replies: 6 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.
-
Hey guys, I might have a same problem but it is reversed. I have posts that has specific categories. I have a single-post template. My problem is that for example, i have a post that has a category 'news' and a uri 'how-to'. Now I can view the content on /news/how-to path. But the problem is that even i replace the url in the browser to /customer/how-to, i can still view the page, basically it should give a 404 page for the /customer/how-to page. Can someone help thank you. basically this is the graphql request SingleNews.variables = ({ uri }) => { SingleNews.query = gql` |
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