What is the purpose of the 'labels' argument in registering a custom post type?
The 'labels' argument defines the text strings used in the WordPress admin area for the custom post type, like menu names and button labels, making the interface clear and user-friendly.
Click to reveal answer
beginner
What does setting 'public' => true do in a custom post type?
Setting 'public' to true makes the custom post type visible on the front end and accessible in the admin UI, allowing users to view and manage the content.
Click to reveal answer
intermediate
Explain the 'supports' argument in custom post type registration.
The 'supports' argument lists features the custom post type supports, like 'title', 'editor', 'thumbnail', enabling those editing options in the admin screen.
Click to reveal answer
intermediate
What is the effect of setting 'has_archive' => true in custom post type arguments?
Setting 'has_archive' to true enables an archive page for the custom post type, where all posts of that type are listed automatically.
Click to reveal answer
advanced
How does the 'rewrite' argument affect a custom post type?
The 'rewrite' argument controls the URL structure (permalinks) for the custom post type, allowing customization of slugs and URL patterns.
Click to reveal answer
Which argument controls if a custom post type appears in the WordPress admin menu?
A'has_archive'
B'public'
C'supports'
D'show_in_menu'
✗ Incorrect
'show_in_menu' determines if the custom post type shows in the admin menu.
What does setting 'exclude_from_search' => true do?
AHides the post type from admin
BIncludes the post type in search results
CExcludes the post type from search results
DDisables permalinks for the post type
✗ Incorrect
Setting 'exclude_from_search' to true hides the post type from front-end search results.
Which argument lets you add support for featured images in a custom post type?
A'thumbnail'
B'supports' with 'thumbnail'
C'has_archive'
D'public'
✗ Incorrect
You add 'thumbnail' inside the 'supports' array to enable featured images.
If you want a custom post type to have its own archive page, which argument should be true?
A'has_archive'
B'public'
C'show_ui'
D'rewrite'
✗ Incorrect
'has_archive' set to true enables an archive page for the post type.
What does the 'capability_type' argument define?
AThe user permissions needed to manage the post type
BThe labels shown in admin
CThe URL slug for the post type
DWhether the post type is public
✗ Incorrect
'capability_type' sets which user permissions control access to the post type.
Describe the key arguments you would set when registering a custom post type to make it public, support titles and editors, and have an archive page.
Think about visibility, editing features, and archive availability.
You got /4 concepts.
Explain how the 'rewrite' argument affects the URLs of a custom post type and why you might want to customize it.
Consider how URLs appear to users and search engines.
You got /5 concepts.
Practice
(1/5)
1. Which argument in register_post_type controls whether the custom post type appears in the WordPress admin menu?
easy
A. public
B. menu_position
C. supports
D. rewrite
Solution
Step 1: Understand the role of menu_position
The menu_position argument sets the location of the custom post type in the WordPress admin menu.
Step 2: Compare with other arguments
public controls visibility on front-end, supports defines features, rewrite controls URL structure.
Final Answer:
menu_position -> Option B
Quick Check:
Admin menu location = menu_position [OK]
Hint: Menu location is set by menu_position argument [OK]
Common Mistakes:
Confusing public with menu visibility
Thinking supports controls menu
Assuming rewrite affects admin menu
2. Which of the following is the correct way to set a custom post type to be publicly queryable in register_post_type arguments?
easy
A. "public_queryable" => true
B. "publiclyqueryable" => true
C. "public_queryable" => "true"
D. "publicly_queryable" => true
Solution
Step 1: Recall the exact argument name
The correct argument is publicly_queryable with an 'ly' and underscore.
Step 2: Check value type and spelling
The value must be boolean true, not string, and spelling must be exact.
Final Answer:
"publicly_queryable" => true -> Option D
Quick Check:
Correct spelling and boolean value = publicly_queryable true [OK]
Hint: Remember 'publicly_queryable' with 'ly' and boolean true [OK]
Common Mistakes:
Misspelling argument name
Using string "true" instead of boolean true
Omitting underscore
3. Given this code snippet, what will be the value of $args['has_archive'] after registration?
A. 'supports' should be an array, not a comma-separated string
B. 'public' should be boolean true, not string 'yes'
C. 'menu_icon' value is invalid, should be a URL
D. No errors, code is correct
Solution
Step 1: Check the supports argument type
supports must be an array of features, not a string.
Step 2: Verify other arguments
public accepts boolean or string 'true'/'false', 'yes' is invalid but PHP may coerce; menu_icon accepts dashicons slug.
Final Answer:
'supports' should be an array, not a comma-separated string -> Option A
Quick Check:
Supports must be array, not string [OK]
Hint: Supports argument must be an array, not a string [OK]
Common Mistakes:
Passing supports as string instead of array
Using invalid string for public
Thinking menu_icon needs URL
5. You want to create a custom post type 'movie' that is public, supports title and editor, has an archive page at '/films', and appears below Posts in the admin menu. Which $args array is correct?
{
'public' => true,
'supports' => ['title', 'editor'],
'has_archive' => true,
'rewrite' => ['slug' => 'films'],
'menu_position' => 5
} sets public to true and supports as an array with 'title' and 'editor', which is correct.
Step 2: Verify archive and rewrite slug
has_archive is true and rewrite slug is 'films' to get archive at '/films'.
Step 3: Confirm menu position
menu_position 5 places it below Posts in admin menu.
Final Answer:
Option A matches all requirements correctly -> Option A