0
0
Wordpressframework~10 mins

Default API endpoints in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get the default REST API base URL in WordPress.

Wordpress
const apiBase = wpApiSettings.[1];
Drag options to blanks, or click blank then click option'
Aendpoint
Broot
Curl
DbaseUrl
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'endpoint' or 'url' instead of 'root'.
Trying to access a property that does not exist.
2fill in blank
medium

Complete the code to fetch posts from the default WordPress REST API endpoint.

Wordpress
fetch(wpApiSettings.root + 'wp/v2/[1]')
Drag options to blanks, or click blank then click option'
Ausers
Bpages
Cposts
Dcomments
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'page' instead of 'pages'.
Using 'users' or 'comments' which are different endpoints.
3fill in blank
hard

Fix the error in the code to get a single post by ID from the WordPress REST API.

Wordpress
fetch(wpApiSettings.root + 'wp/v2/posts/[1]')
Drag options to blanks, or click blank then click option'
ApostId
Bid
C:id
D123
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name instead of an actual ID.
Using ':id' which is not valid in this context.
4fill in blank
hard

Fill both blanks to create a URL to fetch comments for a specific post ID.

Wordpress
const url = wpApiSettings.root + 'wp/v2/[1]/[2]/comments';
Drag options to blanks, or click blank then click option'
Aposts
B123
Cpages
D456
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pages' instead of 'posts' for comments.
Using an invalid post ID.
5fill in blank
hard

Fill all three blanks to build a URL to update a post with ID 789 using the REST API.

Wordpress
fetch(wpApiSettings.root + 'wp/v2/[1]/[2]', { method: '[3]' })
Drag options to blanks, or click blank then click option'
Aposts
B789
CPUT
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'GET' method instead of 'PUT' for updating.
Using wrong content type or post ID.