0
0
Wordpressframework~10 mins

Why metadata extends content in Wordpress - Test Your Understanding

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

Complete the code to add metadata to a WordPress post.

Wordpress
add_post_meta([1], 'color', 'blue');
Drag options to blanks, or click blank then click option'
A$post_id
B$post
C$meta
D$content
Attempts:
3 left
💡 Hint
Common Mistakes
Using the whole post object instead of the post ID.
Confusing metadata key with post content.
2fill in blank
medium

Complete the code to retrieve metadata from a WordPress post.

Wordpress
$color = get_post_meta([1], 'color', true);
Drag options to blanks, or click blank then click option'
A$meta
B$post
C$post_id
D$content
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the entire post object instead of the post ID.
Using the metadata key as the first argument.
3fill in blank
hard

Fix the error in the code to update metadata correctly.

Wordpress
update_post_meta([1], 'color', 'red');
Drag options to blanks, or click blank then click option'
A$post
B$post_id
C$meta
D$content
Attempts:
3 left
💡 Hint
Common Mistakes
Using the post content or meta array instead of the post ID.
Confusing metadata key with post ID.
4fill in blank
hard

Fill both blanks to create metadata and then retrieve it.

Wordpress
add_post_meta([1], 'author', 'Alice');
$author = get_post_meta([2], 'author', true);
Drag options to blanks, or click blank then click option'
A$post_id
B$post
C$content
D$meta
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables for adding and retrieving metadata.
Passing the post object instead of the post ID.
5fill in blank
hard

Fill all three blanks to update metadata, then get it, and finally delete it.

Wordpress
update_post_meta([1], 'status', 'published');
$status = get_post_meta([2], 'status', true);
delete_post_meta([3], 'status');
Drag options to blanks, or click blank then click option'
A$post
B$post_id
C$content
D$meta
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing different variables for metadata functions.
Using post content or meta arrays instead of the post ID.