Challenge - 5 Problems
WordPress REST API Headless Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What is the main advantage of using the WordPress REST API for headless setups?
Why does the WordPress REST API make it easier to build a headless WordPress site?
Attempts:
2 left
💡 Hint
Think about how data is shared between backend and frontend in headless setups.
✗ Incorrect
The WordPress REST API provides content as JSON data. This lets developers build any frontend technology they want, separate from WordPress's PHP-based themes.
❓ component_behavior
intermediate2:00remaining
How does the WordPress REST API affect frontend flexibility in headless sites?
Choose the option that best describes how the REST API impacts frontend development.
Attempts:
2 left
💡 Hint
Consider what frontend technologies can do with JSON data.
✗ Incorrect
The REST API provides content as JSON, so frontend frameworks like React or Vue can consume it and render content independently from WordPress’s PHP templates.
📝 Syntax
advanced2:00remaining
What is the correct REST API endpoint to fetch posts in WordPress?
Select the correct URL path to get a list of posts using the WordPress REST API.
Attempts:
2 left
💡 Hint
WordPress REST API URLs start with /wp-json/ followed by namespace and route.
✗ Incorrect
The standard WordPress REST API endpoint for posts is /wp-json/wp/v2/posts.
🔧 Debug
advanced2:00remaining
Why does this REST API request to fetch posts return a 404 error?
You try to fetch posts from
/wp-json/wp/v2/post but get a 404 error. What is the problem?Attempts:
2 left
💡 Hint
Check the exact endpoint spelling carefully.
✗ Incorrect
The correct endpoint for posts includes a plural 'posts'. Using 'post' causes a 404 because that route does not exist.
❓ state_output
expert2:00remaining
What is the output of this fetch request to WordPress REST API?
Given this JavaScript code fetching posts from WordPress REST API, what will be logged?
Wordpress
fetch('https://example.com/wp-json/wp/v2/posts') .then(response => response.json()) .then(data => console.log(Array.isArray(data))) .catch(() => console.log('error'))
Attempts:
2 left
💡 Hint
Consider what the REST API returns when fetching posts.
✗ Incorrect
The WordPress REST API returns an array of post objects when fetching posts, so Array.isArray(data) will be true.