Content Loaders
dewp/loaders
loads your content using the WordPress REST API so you can use it with Astro’s
content collection API.
component. -->
This project contains several tools for using your WordPress data in Astro projects. You can use them to build headless WordPress sites with Astro or even migrate your data away from WordPress to Astro entirely.
Content Loaders
dewp/loaders
loads your content using the WordPress REST API so you can use it with Astro’s
content collection API.
Starter Template
Use DeWP’s blog template to get started with an Astro project using headless WordPress data.
More coming soon!
The easiest way to get started is to create a new Astro project using the DeWP blog template.
Run the following command in your terminal and follow the instructions in the Astro install wizard.
Update the endpoint
option in src/content/config.ts
to the URL of your WordPress REST API. Most commonly this is the URL of your website with /wp-json/
at the end.
You can now start the Astro dev server and see a live preview of your project while you build.
The template shows links to all the pages in the linked WordPress site on the homepage and links to the 10 most recent blog posts at /blog
.
If you prefer to add the DeWP content loaders to an existing Astro project, follow these steps.
Install DeWP by running the following command in your project directory.
Add the DeWP content loaders to src/content/config.ts
, setting endpoint
to the URL of your WordPress REST API.
You can now use Astro’s content collection APIs to get your WordPress data in your components.
In the following example, the posts
collection is loaded in order to display each post’s title: