Performance: Custom post type arguments
This affects page load speed and rendering by controlling how WordPress registers and displays custom content types, impacting query complexity and asset loading.
register_post_type('book', array('public' => true, 'has_archive' => true, 'supports' => array('title', 'editor'), 'show_in_rest' => false));
register_post_type('book', array('public' => true, 'has_archive' => true, 'supports' => array('title', 'editor', 'thumbnail', 'comments', 'revisions', 'author', 'excerpt', 'custom-fields'), 'show_in_rest' => true));
| Pattern | Query Complexity | Asset Load | Rendering Impact | Verdict |
|---|---|---|---|---|
| Many supports enabled | High - multiple joins and meta queries | High - loads extra scripts/styles | Slower LCP due to heavy queries and assets | [X] Bad |
| Minimal supports and no extra taxonomies | Low - simple queries | Low - fewer scripts/styles | Faster LCP with leaner page load | [OK] Good |
register_post_type controls whether the custom post type appears in the WordPress admin menu?menu_positionmenu_position argument sets the location of the custom post type in the WordPress admin menu.public controls visibility on front-end, supports defines features, rewrite controls URL structure.register_post_type arguments?publicly_queryable with an 'ly' and underscore.true, not string, and spelling must be exact.$args['has_archive'] after registration?$args = [
'public' => true,
'has_archive' => false,
'rewrite' => ['slug' => 'books']
];
register_post_type('book', $args);has_archive argument valuefalse in the array.rewrite on has_archiverewrite argument does not override has_archive setting.register_post_type argument array:$args = [
'public' => 'yes',
'supports' => 'title,editor',
'menu_icon' => 'dashicons-book'
];
register_post_type('book', $args);supports argument typesupports must be an array of features, not a string.public accepts boolean or string 'true'/'false', 'yes' is invalid but PHP may coerce; menu_icon accepts dashicons slug.$args array is correct?public to true and supports as an array with 'title' and 'editor', which is correct.has_archive is true and rewrite slug is 'films' to get archive at '/films'.menu_position 5 places it below Posts in admin menu.Pass the test and this pattern moves unknown