Bird
Raised Fist0
Wordpressframework~20 mins

Custom post type arguments in Wordpress - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Custom Post Type Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
What is the effect of 'public' => false in a custom post type?
Consider this custom post type registration snippet:
register_post_type( 'book', array( 'public' => false, 'show_ui' => true ) );

What will be the visible behavior in the WordPress admin dashboard?
Wordpress
register_post_type( 'book', array( 'public' => false, 'show_ui' => true ) );
AThe post type is hidden both in admin UI and front-end.
BThe post type is visible on the front-end but hidden in admin UI.
CThe post type is visible both in admin UI and front-end.
DThe post type is visible in admin UI but not accessible on the front-end.
Attempts:
2 left
💡 Hint
Think about what 'public' controls versus 'show_ui'.
📝 Syntax
intermediate
2:00remaining
Which argument correctly enables REST API support for a custom post type?
You want your custom post type to be accessible via the WordPress REST API. Which argument must be set to true in register_post_type?
Wordpress
register_post_type( 'movie', array( /* arguments here */ ) );
A'show_in_rest' => true
B'rest_support' => true
C'enable_rest' => true
D'rest_api' => true
Attempts:
2 left
💡 Hint
Look for the exact argument name used in WordPress documentation.
❓ state_output
advanced
2:00remaining
What is the slug used in URLs for this custom post type?
Given this registration code:
register_post_type( 'album', array( 'rewrite' => array( 'slug' => 'music' ), 'public' => true ) );

What will be the base URL slug for single 'album' posts?
Wordpress
register_post_type( 'album', array( 'rewrite' => array( 'slug' => 'music' ), 'public' => true ) );
A/music/{post-name}/
B/album/{post-name}/
C/albums/{post-name}/
D/post/{post-name}/
Attempts:
2 left
💡 Hint
The 'rewrite' argument controls the URL slug.
🔧 Debug
advanced
2:00remaining
Why does this custom post type not appear in the admin menu?
This code registers a custom post type but it does not show in the WordPress admin menu:
register_post_type( 'event', array( 'public' => true, 'show_ui' => false ) );

What is the cause?
Wordpress
register_post_type( 'event', array( 'public' => true, 'show_ui' => false ) );
A'show_in_menu' must be true to appear in admin menu.
B'show_ui' is false, so admin menu is hidden.
CMissing 'menu_position' argument causes it to be hidden.
D'public' must be false to show in admin menu.
Attempts:
2 left
💡 Hint
Check the meaning of 'show_ui' argument.
🧠 Conceptual
expert
3:00remaining
Which argument controls whether a custom post type supports hierarchical parent-child relationships?
You want your custom post type to behave like pages, allowing parent and child posts. Which argument enables this?
A'supports' => ['parent']
B'parentable' => true
C'hierarchical' => true
D'nested' => true
Attempts:
2 left
💡 Hint
Think about the argument that controls post relationships.

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

  1. 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.
  2. Step 2: Compare with other arguments

    public controls visibility on front-end, supports defines features, rewrite controls URL structure.
  3. Final Answer:

    menu_position -> Option B
  4. 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

  1. Step 1: Recall the exact argument name

    The correct argument is publicly_queryable with an 'ly' and underscore.
  2. Step 2: Check value type and spelling

    The value must be boolean true, not string, and spelling must be exact.
  3. Final Answer:

    "publicly_queryable" => true -> Option D
  4. 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?
$args = [
  'public' => true,
  'has_archive' => false,
  'rewrite' => ['slug' => 'books']
];
register_post_type('book', $args);
medium
A. true
B. null
C. false
D. array with slug 'books'

Solution

  1. Step 1: Check the has_archive argument value

    It is explicitly set to false in the array.
  2. Step 2: Understand effect of rewrite on has_archive

    The rewrite argument does not override has_archive setting.
  3. Final Answer:

    false -> Option C
  4. Quick Check:

    Explicit has_archive false remains false [OK]
Hint: Explicit has_archive false stays false despite rewrite [OK]
Common Mistakes:
  • Assuming rewrite slug enables archive
  • Confusing has_archive with rewrite
  • Thinking default true overrides false
4. Identify the error in this register_post_type argument array:
$args = [
  'public' => 'yes',
  'supports' => 'title,editor',
  'menu_icon' => 'dashicons-book'
];
register_post_type('book', $args);
medium
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

  1. Step 1: Check the supports argument type

    supports must be an array of features, not a string.
  2. Step 2: Verify other arguments

    public accepts boolean or string 'true'/'false', 'yes' is invalid but PHP may coerce; menu_icon accepts dashicons slug.
  3. Final Answer:

    'supports' should be an array, not a comma-separated string -> Option A
  4. 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?
hard
A. { 'public' => true, 'supports' => ['title', 'editor'], 'has_archive' => true, 'rewrite' => ['slug' => 'films'], 'menu_position' => 5 }
B. { 'public' => true, 'supports' => ['title', 'editor'], 'has_archive' => 'films', 'rewrite' => true, 'menu_position' => 20 }
C. { 'public' => true, 'supports' => 'title,editor', 'has_archive' => true, 'rewrite' => ['slug' => 'movies'], 'menu_position' => 5 }
D. { 'public' => false, 'supports' => ['title', 'editor'], 'has_archive' => true, 'rewrite' => ['slug' => 'films'], 'menu_position' => 5 }

Solution

  1. Step 1: Check public visibility and supports

    { '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.
  2. Step 2: Verify archive and rewrite slug

    has_archive is true and rewrite slug is 'films' to get archive at '/films'.
  3. Step 3: Confirm menu position

    menu_position 5 places it below Posts in admin menu.
  4. Final Answer:

    Option A matches all requirements correctly -> Option A
  5. Quick Check:

    Public, supports array, archive slug, menu position 5 = { 'public' => true, 'supports' => ['title', 'editor'], 'has_archive' => true, 'rewrite' => ['slug' => 'films'], 'menu_position' => 5 } [OK]
Hint: Use array for supports, boolean for public, correct slug in rewrite [OK]
Common Mistakes:
  • Passing supports as string instead of array
  • Setting public false when it should be true
  • Incorrect has_archive or rewrite values
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard