Learn how to fine-tune your WordPress CPT arguments. Master supports, rewrite slugs, and hierarchical structures to build a professional Knowledge Base.
Previously in this course, we covered the basics of Registering Custom Post Types using the register_post_type function. In this lesson, we will move beyond the default settings to fine-tune our "Knowledge Article" CPT with advanced configuration arguments.
Proper CPT configuration is the difference between a functional post type and a professional-grade feature. By controlling supports, hierarchy, and URL structure, you ensure your plugin behaves exactly as your users expect.
supports ArgumentWhen you register a CPT, WordPress defaults to a very minimal setup. To make our Knowledge Articles useful, we must explicitly enable the features that our users need. The supports argument accepts an array of strings that tell WordPress which UI elements to render in the editor.
For our Knowledge Base plugin, we want our articles to have a title, body content, and a featured image. We should also enable revisions so users can track changes.
PHP$args = array( 'supports' => array( 'title', 'editor', 'thumbnail', 'revisions', 'excerpt' ), #6A9955">// ... other arguments );
If you omit this argument, WordPress defaults to only title and editor. Adding thumbnail is critical if you plan to display these articles with featured images in a grid or list view.
rewriteBy default, WordPress uses the CPT name as the URL slug. If your CPT is registered as kb_article, your URLs will look like example.com/kb_article/my-article-title. This is often not ideal for SEO or branding.
The rewrite argument allows you to customize the URL structure. You can pass a boolean false to disable rewrites, or an associative array to define a custom slug.
PHP'rewrite' => array( 'slug' => 'knowledge-base', 'with_front' => false, ),
Setting with_front to false is a pro tip: it prevents your custom slug from being prefixed by your site's base permalink structure (e.g., /blog/knowledge-base/). For a deeper look at how WordPress processes these patterns, refer to WordPress rewrite rules: How Regex Patterns Generate from Permalinks.
Most custom post types behave like blog posts (flat lists). However, a Knowledge Base often benefits from parent-child relationships, where one article acts as a category or a "parent" to several sub-articles.
To enable this, we set hierarchical to true and ensure page-attributes is added to the supports array.
PHP'hierarchical' => true, 'supports' => array('title', 'editor', 'page-attributes'),
When hierarchical is set to true, the post editor will display a "Parent" dropdown in the sidebar, allowing you to nest articles. This changes the URL structure if you include the parent slug, creating a logical tree for your documentation.
Open your CPT registration class. Update your register_post_type arguments to include the following configuration:
title, editor, thumbnail, and page-attributes.kb-articles and ensure with_front is false.hierarchical to true.After saving the file, you must visit the Permalinks settings page in your WordPress dashboard to flush the rewrite rules. If you skip this step, your new URLs will likely return a 404 error.
rewrite argument, you must trigger a rewrite rule refresh.supports will include everything you need. If a feature (like thumbnail or excerpt) isn't working, check your supports array first.hierarchical to true but forget page-attributes in your supports array, you won't see the parent-child UI in the editor, even though the database logic is enabled.We have successfully advanced our Knowledge Base plugin by configuring the CPT to support modern editing features and clean, custom URL structures. By using supports, rewrite, and hierarchical arguments, we've transformed a basic post type into a structured content system.
Up next: We will organize our content further by learning how to add custom taxonomies to our Knowledge Article CPT.
Learn to extend the WordPress REST API by registering custom endpoints. We'll show you how to securely serve your Knowledge Base data as structured JSON.
Configuring CPT Arguments
Plugin Security Best Practices
Composer for Dependencies
Theme Integration Hooks
Managing Assets with Gulp/Webpack
Documentation Standards
Plugin Deployment Strategy
Advanced MVC: Dependency Injection
Handling Large Datasets
Error Handling and Logging