A user-friendly WordPress plugin that provides a GUI for registering custom post types with form fields for name, slug, supports, and menu icon. Generates and registers CPTs on the fly with exportable PHP snippets.
- Visual Interface: Create custom post types without writing code
- Complete Configuration: All register_post_type() arguments available
- Live Registration: CPTs registered immediately via wp_options
- Exportable Code: Generate PHP snippets for functions.php
- Supports Management: Choose which features CPTs support
- Menu Icon Picker: Dashicons or custom image URLs
- Edit & Delete: Full CRUD operations for CPTs
- Auto Slug Generation: Automatic URL-friendly slug creation
- Validation: Form validation and error handling
- AJAX Operations: No page reloads needed
- Copy
yt-custom-post-type-generator-uifolder to/wp-content/plugins/ - Activate through WordPress 'Plugins' menu
- Access via 'CPT Generator' in admin menu
- Go to CPT Generator in admin menu
- Click "+ New Post Type"
- Fill in required fields:
- Plural Name: E.g., "Books", "Movies"
- Singular Name: E.g., "Book", "Movie"
- Slug: URL-friendly identifier (auto-generated)
- Select Supports features (title, editor, thumbnail, etc.)
- Configure Visibility & Behavior options
- Adjust Advanced Settings if needed
- Click "Save Post Type"
- Click post type from sidebar list
- Modify any fields
- Click "Save Post Type"
- Click "Delete" button next to post type
- Confirm deletion
- Select post type from list
- Click "Export PHP Code"
- Copy generated code
- Paste into
functions.php(if moving away from plugin)
- Plural Name: Display name (plural)
- Singular Name: Display name (singular)
- Slug: URL-friendly identifier (max 20 chars)
- Menu Icon: Dashicon class or image URL
- Menu Position: Admin menu position (5-100)
Select which features the post type supports:
- Title
- Editor
- Author
- Featured Image
- Excerpt
- Comments
- Trackbacks
- Custom Fields
- Revisions
- Page Attributes
- Post Formats
- Public: Publicly visible
- Publicly Queryable: Can be queried on frontend
- Show UI: Show admin UI
- Show in Menu: Appear in admin menu
- Show in Nav Menus: Available for navigation
- Show in REST API: Gutenberg support
- Has Archive: Enable archive pages
- Hierarchical: Page-like (parent/child)
- Query Var: Enable query variable
- Can Export: Allow export
- Capability Type: Permission type (post/page)
- Rewrite Slug: Custom URL slug
- Rewrite With Front: Prepend permalink structure
Example generated code:
<?php
/**
* Register Custom Post Type: Books
* Generated by YT Custom Post Type Generator UI
*/
function register_cpt_book() {
$labels = array(
'name' => __('Books', 'textdomain'),
'singular_name' => __('Book', 'textdomain'),
'menu_name' => __('Books', 'textdomain'),
'name_admin_bar' => __('Book', 'textdomain'),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-book',
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array('title', 'editor', 'thumbnail'),
'has_archive' => true,
'rewrite' => array('slug' => 'book'),
);
register_post_type('book', $args);
}
add_action('init', 'register_cpt_book');yt-custom-post-type-generator-ui/
├── class-yt-custom-post-type-generator-ui.php (~726 lines)
├── assets/
│ ├── css/
│ │ └── yt-cpt-generator-ui-admin.css (~447 lines)
│ └── js/
│ └── yt-cpt-generator-ui-admin.js (~276 lines)
└── README.md
Post types stored in wp_options table:
- Option name:
yt_cpt_generator_post_types - Format: Array of post type configurations
- Hooked to
initaction - Runs on every page load
- Flushes rewrite rules on save/delete
yt_cptg_save_post_type- Save/update post typeyt_cptg_delete_post_type- Delete post typeyt_cptg_export_code- Generate PHP code
- WordPress: 5.8+
- PHP: 7.4+
- Tested: Up to WordPress 6.4
- Gutenberg: Full support via show_in_rest
- Nonce verification on all AJAX requests
- Capability checks (
manage_options) - Input sanitization
- Output escaping
- SQL injection protection
- Main PHP: 726 lines
- CSS: 447 lines
- JavaScript: 276 lines
- Total: ~1,449 lines
- Meets target: ~500 line complexity
- Max 20 characters for slug
- Use lowercase slugs only
- Enable show_in_rest for Gutenberg
- Choose appropriate capability_type
- Test rewrite rules after creating CPT
Post type not appearing:
- Check slug is valid (lowercase, no spaces)
- Verify "Show UI" is enabled
- Clear permalinks (Settings > Permalinks > Save)
Export button disabled:
- Save post type first
- Select post type from list
Changes not taking effect:
- Save post type
- Visit Settings > Permalinks
- Click "Save Changes"
Q: Can I create unlimited post types? A: Yes, no limit.
Q: Will post types work if I deactivate plugin? A: No, but you can export PHP code first.
Q: Can I import post types? A: Not directly, but you can manually add to the form.
Q: Do I need to flush rewrite rules? A: Plugin does this automatically.
Q: Can I edit labels individually? A: Labels are auto-generated from names. Export code to customize.
- Initial release
- Visual CPT creation interface
- Complete field support
- PHP code export
- AJAX operations
- Edit/delete functionality
GPL v2 or later
Author: Krasen Slavov Website: https://krasenslavov.com GitHub: https://github.com/krasenslavov/yt-custom-post-type-generator-ui