Quick overview of the steps we'll cover
Fetch endpoints using WordPress documentation
- Retrieve all categories to list them in our navigation.
- Fetch a category based on the slug of the current page URL.
- Get all posts associated with the category ID of the current page.
Connect data from endpoints
- List all categories from endpoint 1.
- Create a single category page and connect its data using API 2.
- On the single category page, display all posts belonging to the current category using API 3.
Style category link
Ensure the current category link in the navigation has a different style.
REST API video tutorial: A step-by-step guide
How to prepare endpoints from WordPress
First, we need to prepare three endpoints that we need. In the next step, we will use Divhunt REST API application and connect those 3 endpoints that we can use in the builder.
Retrieve all categories
Using the endpoint below, we will fetch up to 30 categories from WordPress. For each category, we will store only the ID, slug, and name.
https://yourwebsite.com/wp-json/wp/v2/categories?per_page=30&_fields=id,slug,name
Retrieve category by slug
Using the endpoint below, we will fetch data for a specific category based on its slug. Later, in Divhunt, we will dynamically provide the slug from the page URL using the REST API.
https://yourwebsite.com/wp-json/wp/v2/categories?slug=CATEGORY_SLUG
Get posts of current category
Using the endpoint below, we will fetch posts that belong to a specific category using its ID. Later, in Divhunt, we will dynamically provide the category ID from the page data using the REST API.
https://yourwebsite.com/wp-json/wp/v2/posts?categories=CATEGORY_ID
Connect WordPress endpoints with Divhunt easily
In the Divhunt REST API application, we will need to create three GET requests.
The first request will retrieve up to 30 categories from WordPress. The second request will fetch data for a specific category based on the page URL slug. The third request will get all posts that belong to the category of the current page.
These requests will allow us to dynamically display categories and their associated posts on our website.
Get all categories
- In the URL (Endpoint) field, paste the URL that we generated previously.
- Ensure the "Source" option is checked under the settings tab.
- Click the execute icon in the middle of the top bar to verify everything is working correctly. If you see a JSON data preview on the right (as shown in the screenshot), everything is correct, and we are ready to use this data in the builder.
- Now this data is ready to be used later in builder.

Get single category based on a page URL (dynamic slug)
- In the URL (Endpoint) field, paste the URL that we generated previously.
- Ensure the "Source" option is checked under the settings tab.
- Create a dynamic property slug with the default value. (see screenshot 2 below)
- Use this property as dynamic slug in our endpoint instead of static slug '${properties->get('slug')}'. (screenshot 1 below)
- Click the execute icon in the middle of the top bar to verify everything is working correctly. If you see a JSON data preview on the right (as shown in the screenshot), everything is correct, and we are ready to use this data in the builder.
- Now this data is ready to be used later in builder.


Get posts of current category
- In the URL (Endpoint) field, paste the URL that we generated previously.
- Ensure the "Source" option is checked under the settings tab.
- Create a dynamic property categoryid with the default value. (see screenshot 2 below)
- Use this property as dynamic category id in our endpoint instead of static category id '${properties->get('categoryid')}'. (see screenshot 1 below)
- Click the execute icon in the middle of the top bar to verify everything is working correctly. If you see a JSON data preview on the right (as shown in the screenshot), everything is correct, and we are ready to use this data in the builder.
- Now this data is ready to be used later in builder.


Now all this data is being stored under the Source of your website, and you can use it to display information on your website. Click here to learn more about Source.
