So what I’ve done is I’ve created a custom post type using the (CPT) WordPress plugin, and I can’t seem to access it.
Its archive is set to “/reviews”, and it shows up if I access it inside of WordPress. But nothing happens in Frontity I’ve set the custom post type, and it shows up inside of Frontity state too.
This is an excert from my code that returns undefined:
Hi, you should read here about the frontity lifecycle
SSR = serverside rendering
CSR = clientside rendering
Since you need the content available on your page at the beginning (so search engines can see the static content etc), then you want to gather the data beforeSSR
Don’t have an example to hand but next time I’m at the PC I’ll try find some code.
There should be some examples on the forum if you search beforeSSR though
It takes a while to understand the lifecycle and where/when you need to fetch data accordingly but it’s not too complicated overall
For future reference, this is exactly what I changed and where:
index.js
I added this action to actions/theme to make it pre-fetch the reviews. beforeSSR: async({actions}) => { await actions.source.fetch("/reviews"); }
Then in the page I wanted to grab the information
I simply just did the same thing as before, where reviews is my custom post type. const reviews = state.source.get("/reviews").items