0
0
Wordpressframework~10 mins

Custom post type arguments 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 register a custom post type with the label 'Books'.

Wordpress
register_post_type('book', array('label' => [1]));
Drag options to blanks, or click blank then click option'
A'Book'
B'books'
C'Books'
D'book'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the post type slug instead of a label.
Not using quotes around the label.
2fill in blank
medium

Complete the code to make the custom post type publicly queryable.

Wordpress
register_post_type('movie', array('public' => [1]));
Drag options to blanks, or click blank then click option'
A'false'
Bfalse
C'true'
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings 'true' or 'false' instead of booleans.
Setting 'public' to false which hides the post type.
3fill in blank
hard

Fix the error in the code to enable the post type to support the editor and thumbnail features.

Wordpress
register_post_type('album', array('supports' => array([1])));
Drag options to blanks, or click blank then click option'
A'title', 'editor'
B'editor', 'thumbnail'
D'editor', 'comments'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single string instead of an array.
Missing 'thumbnail' if you want featured images.
4fill in blank
hard

Fill both blanks to register a custom post type that is hierarchical and has a custom menu icon.

Wordpress
register_post_type('product', array('hierarchical' => [1], 'menu_icon' => [2]));
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
C'dashicons-cart'
D'dashicons-admin-post'
Attempts:
3 left
💡 Hint
Common Mistakes
Using false for 'hierarchical' when parent-child is needed.
Not using quotes around the dashicon string.
5fill in blank
hard

Fill all three blanks to register a custom post type with a custom rewrite slug, showing it in REST API, and enabling archive pages.

Wordpress
register_post_type('event', array('rewrite' => array('slug' => [1]), 'show_in_rest' => [2], 'has_archive' => [3]));
Drag options to blanks, or click blank then click option'
A'events'
Btrue
Cfalse
D'event'
Attempts:
3 left
💡 Hint
Common Mistakes
Using false for 'show_in_rest' which disables REST API support.
Not using quotes around the slug string.
Setting 'has_archive' to false when archive pages are needed.