WordPress Custom Post Type Generator

Generate register_post_type() code with Basic and Advanced options — copy/paste or download a ready PHP snippet.
All Tools
No plugins • Clean code • Copy & Download
Used for admin labels like “Add New Book”.
Used for menu labels like “Books”.
Lowercase + underscores only. This becomes the post type key.
Controls public URLs: /books/my-book.
Controls which editor fields appear when creating the post type.
Public CPTs can be shown on front-end and in search (depending on settings).
Enables archive page: /books.
Needed for Gutenberg & REST endpoints.

Where to paste: functions.php (child theme recommended) or a small custom plugin file. After adding/replacing a CPT, go to Settings → Permalinks → Save to flush rewrite rules.

Generate WordPress Custom Post Type code in seconds

A WordPress Custom Post Type (CPT) lets you create structured content beyond posts and pages — like Portfolio, Books, Products, Events, Testimonials, or Real Estate Listings. This generator creates clean, copy-paste register_post_type() code with the correct labels, rewrite rules, editor supports, and REST API settings.

Use Basic mode for quick CPT setup, or Advanced mode when you need full control over visibility, admin menu behavior, permalinks, archive pages, and capabilities.

Common CPT examples

  • Portfolio (projects, case studies)
  • Books (authors, genres, ISBN metadata)
  • Events (date, venue, speakers)
  • Products (custom product catalogs)
  • Testimonials (reviews, ratings)

Frequently Asked Questions (FAQ)

1. What is a Custom Post Type in WordPress?

A CPT is a content type you register in WordPress so you can manage items like “Portfolio” or “Events” separately from regular posts.

2. Where do I add the generated CPT code?

Paste it into your theme’s functions.php (preferably a child theme) or create a small plugin and place the code there.

3. Why is my CPT not showing on the front-end?

Check public and publicly_queryable, and ensure rewrite rules are flushed by saving Permalinks.

4. Do I need “show_in_rest” enabled?

Yes if you want Gutenberg support and REST API endpoints. Disable only if you have a specific reason.

5. What does “has_archive” do?

It creates an archive listing page for the CPT (example: /books) if rewrite is enabled.

6. What are “supports” in a CPT?

Supports define which editor features appear (title, editor, thumbnail, excerpt, custom fields, etc.).

7. Can I attach categories and tags to a CPT?

Yes. Add category and/or post_tag in the Taxonomies field (or register custom taxonomies).

8. What is the difference between “public” and “show_ui”?

public impacts front-end visibility; show_ui controls whether admin screens are shown.

9. Do I need to flush rewrite rules?

Usually yes after adding or changing rewrite slugs. Go to Settings → Permalinks → Save.

10. Will this slow down my website?

No. Registering a CPT is lightweight. Performance depends on your queries, templates, and plugins.

Quick tips
  • Use a child theme or plugin so code updates don’t overwrite changes.
  • Choose a stable rewrite slug early to avoid broken URLs later.
  • Enable “show_in_rest” for Gutenberg + headless use.
Popular slugs
portfolio books events testimonials products
Safety note
This generator does not store inputs and does not call external APIs. Code is produced in your browser.