Mahamudul Hasan Rubel
HomeAboutProjectsSkillsExperienceBlogCoursesPhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • About
  • Projects
  • Skills
  • Experience
  • Blog
  • Courses
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
Lesson 11 of the WordPress Plugin Development: Foundations (PHP & MVC) course
WordPressJune 25, 20263 min read

Configuring CPT Arguments: Mastering Knowledge Article Registration

Learn how to fine-tune your WordPress CPT arguments. Master supports, rewrite slugs, and hierarchical structures to build a professional Knowledge Base.

WordPressPHPCPTDevelopmentPlugin Developmentplugin-development

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.

The Power of the supports Argument

When 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.

Controlling URL Structure with rewrite

By 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.

Implementing Hierarchical Support

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.

Hands-on Exercise: Refining the Knowledge Article

Open your CPT registration class. Update your register_post_type arguments to include the following configuration:

  1. Supports: Add title, editor, thumbnail, and page-attributes.
  2. Rewrite: Set the slug to kb-articles and ensure with_front is false.
  3. Hierarchical: Set 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.

Common Pitfalls

  • Forgetting to Flush Permalinks: This is the #1 cause of "my new CPT returns a 404." Whenever you change a rewrite argument, you must trigger a rewrite rule refresh.
  • Assuming Defaults: Never assume supports will include everything you need. If a feature (like thumbnail or excerpt) isn't working, check your supports array first.
  • Hierarchical Confusion: If you set 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.

Recap

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.

Previous lessonRegistering Custom Post TypesNext lesson Introduction to Taxonomies
Back to Blog

Similar Posts

WordPressWordPressJune 25, 20264 min read

Understanding WordPress Hooks: Actions vs. Filters Explained

Master the WordPress event-driven architecture. Learn the difference between actions and filters and how to implement callbacks to build robust plugins.

Read more
WordPressWordPressJune 25, 2026

Part of the course

WordPress Plugin Development: Foundations (PHP & MVC)

beginner · Lesson 11 of 47

  1. 1

    Plugin Anatomy and File Structure

    3 min
  2. 2

    The Plugin Lifecycle Hooks

    4 min
  3. 3

    Designing for MVC in WordPress

    3 min
3 min read

REST API Integration: Exposing Data for External Consumption

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.

Read more
WordPressWordPressJune 25, 20263 min read

Capability Checks: Securing WordPress Plugins with Authorization

Master WordPress security by implementing capability checks. Learn to use current_user_can to restrict admin features and enforce proper access control.

Read more
4

Defining the Plugin Core Class

4 min
  • 5

    Understanding WordPress Hooks

    4 min
  • 6

    Implementing Custom Action Hooks

    4 min
  • 7

    Managing Hook Priorities

    3 min
  • 8

    Creating Admin Menus

    3 min
  • 9

    The Controller Layer for Admin Pages

    3 min
  • 10

    Registering Custom Post Types

    3 min
  • 11

    Configuring CPT Arguments

    3 min
  • 12

    Introduction to Taxonomies

    3 min
  • 13

    Designing Meta-Boxes

    3 min
  • 14

    Sanitizing User Input

    4 min
  • 15

    Saving Meta Data

    3 min
  • 16

    Database Basics with wpdb

    3 min
  • 17

    Secure CRUD Operations

    3 min
  • 18

    Querying with WP_Query

    3 min
  • 19

    Optimizing Queries

    3 min
  • 20

    The Model Layer for Data

    3 min
  • 21

    Enqueuing Scripts and Styles

    3 min
  • 22

    Plugin Template Hierarchy

    3 min
  • 23

    Creating Frontend Templates

    3 min
  • 24

    Building Shortcodes

    3 min
  • 25

    Advanced Shortcode Logic

    3 min
  • 26

    Introduction to Gutenberg Blocks

    3 min
  • 27

    The Settings API

    3 min
  • 28

    Validating Settings

    3 min
  • 29

    Implementing Nonces

    3 min
  • 30

    Capability Checks

    3 min
  • 31

    Handling Plugin Updates

    3 min
  • 32

    Internationalization (i18n)

    3 min
  • 33

    Debugging WordPress Plugins

    4 min
  • 34

    Unit Testing Foundations

    3 min
  • 35

    Handling AJAX Requests

    3 min
  • 36

    REST API Integration

    3 min
  • 37

    Advanced Database Queries

    3 min
  • 38

    Caching Strategies

    3 min
  • 39

    Plugin Security Best Practices

    Coming soon
  • 40

    Composer for Dependencies

    Coming soon
  • 41

    Theme Integration Hooks

    Coming soon
  • 42

    Managing Assets with Gulp/Webpack

    Coming soon
  • 43

    Documentation Standards

    Coming soon
  • 44

    Plugin Deployment Strategy

    Coming soon
  • 45

    Advanced MVC: Dependency Injection

    Coming soon
  • 46

    Handling Large Datasets

    Coming soon
  • 47

    Error Handling and Logging

    Coming soon
  • View full course