Data
Last updated
Was this helpful?
Last updated
Was this helpful?
Since we can’t determine the post type of pages vs posts by URI (due to how the permalinks are structured for those) we need to refactor to query all pages and post types like this.
This greatly simplifies how we’re handling routing since it will eliminate the need for subdirectories under the /frontend/pages
path. With that in place we can simply dynamically render the correct single-item template (post/page/product/promotion/location, etc.) based on the post type of the node that’s returned.
We can pull JSON data from Sitefinity sites like this.
You can connect to the demo site's database to work with large data sets to save time. Just make the backend localhost url the same as the dev site url in the constants.ts
file.
You can switch to the dev db to work with some actual data on the frontend. Just be sure not to alter it in any way. For alterations, you can export the data from WPAllImport
By default, posts come from the JSON API with only the ID of a featured image. But, there are embedded fields that can be utilized to get the image data.
This is what the image data looks like in a loop over that array of posts when called from the frontend component.
Here we are getting an array of posts from the WP database using . The third argument allows us to add options. When we set _embed
to true, we get the extended data that we need to display images on the frontend.
Paste this curl request into to manually revalidate cache.