Skip to main content

WordPress Custom Post Type Generator

Generate complete custom post types with taxonomies, meta boxes, REST API support, admin columns, and archive templates for WordPress.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
You are a WordPress developer. Help me create a complete custom post type system for a real estate listing WordPress site.

Step 1: Register the property custom post type in a custom plugin at wp-content/plugins/custom-properties. Configure all arguments: labels (singular, plural, menu name, and all admin labels), public visibility, REST API support (show_in_rest = true), supported features (title, editor, thumbnail, excerpt, revisions, custom-fields), menu icon (dashicons-building), hierarchical setting, archive slug (properties), and rewrite rules. Use the custom-properties text domain for all translatable strings. Register on the init hook with priority 10.

Step 2: Create 3 custom taxonomies for the post type. For each taxonomy, configure: labels, hierarchical (category-like) vs non-hierarchical (tag-like), REST API support, admin UI column, and custom rewrite slug. Register the taxonomies and associate them with the property post type. Implement default terms that are created on plugin activation using register_activation_hook.

Step 3: Build custom meta boxes for the post type editor. Create 8 custom fields: price, bedrooms, bathrooms, square_footage, address, listing_date, agent_name, virtual_tour_url. Use the CMB2 library approach for meta box rendering. Register each meta field with register_post_meta() for REST API exposure. Add proper sanitization callbacks (sanitize_text_field, absint, wp_kses_post) and validation. Save meta data on the save_post_{cpt_name} hook with nonce verification and capability checks.

Step 4: Customize the admin list table for the post type. Add 4 custom columns displaying: price, bedrooms, listing date, featured image. Make sortable columns use proper orderby meta queries. Add quick edit support for the most commonly edited fields. Implement bulk edit actions for mark as featured / mark as sold. Add admin filters (dropdown) for each taxonomy in the list table header.

Step 5: Create the archive and single templates. Build archive-property.php with: a filterable grid/list view, taxonomy filter dropdowns, pagination, and posts per page set to 12. Build single-property.php with: the full content display, custom meta field output, related items (same taxonomy), and navigation to previous/next items. Use template_include filter with plugin templates for template loading in the plugin.

Step 6: Implement advanced features: custom REST API endpoints for filtered queries (e.g., /wp-json/custom-properties/v1/property?taxonomy=value), pre_get_posts modification for custom default ordering, custom Gutenberg block for embedding property items in other posts, and an import/export tool that handles CSV files for bulk content management. Write PHPUnit tests for the registration and REST API endpoints.

What this prompt does

This prompt turns the model into a WordPress developer building a complete custom post type system for a [site_type] site. It produces six artifacts: registration of the [cpt_name] post type, [taxonomy_count] taxonomies, [meta_field_count] meta boxes, a customized admin list table, archive and single templates, and advanced REST and Gutenberg features.

The value is in doing the boring-but-critical parts correctly. The post type registers on the init hook with REST support and the [supports] features, taxonomies register with default terms on activation, and meta fields use register_post_meta() with sanitization callbacks and nonce-checked saves on save_post_{cpt_name}. The admin table gets [column_count] columns showing [custom_columns], sortable via meta queries, plus bulk actions for [bulk_action]. Templates load through the [template_approach].

The sixth step is where it goes beyond a basic generator. It adds custom REST endpoints under [api_namespace] for filtered queries, a pre_get_posts modification for default ordering, a Gutenberg block for embedding [cpt_name] items inside other posts, and an import/export tool for [import_format] bulk content. It also calls for PHPUnit tests on the registration and REST endpoints, since those are exactly the pieces that break silently during later refactors. Doing all of this on the correct hooks with capability checks is what separates a production post type from a fragile one.

When to use it

  • Your site needs structured content beyond posts and pages, like a [cpt_name] type.
  • You want taxonomies, meta fields, and admin columns generated together, not piecemeal.
  • You need the post type exposed in the REST API for a headless or app front end.
  • Editors need a usable admin list with sortable columns and filters.
  • You want archive and single templates shipped from a plugin, not the theme.
  • You need an import/export tool for [import_format] bulk content management.

Example output

Expect plugin code and structure: a registration block for [cpt_name] at [plugin_directory] with the [menu_icon] icon and [archive_slug] archive, [taxonomy_count] taxonomy registrations with default terms, [meta_field_count] meta fields ([meta_fields]) wired via the [meta_box_approach], an admin table with [custom_columns], archive and single templates showing [posts_per_page] items, plus custom REST endpoints under [api_namespace] and PHPUnit tests.

Pro tips

  • Choose [cpt_name] and [archive_slug] carefully; rewrite rules and URLs depend on them and changing slugs later breaks links.
  • List your real fields in [meta_fields] so the generated meta boxes match the content model, not a generic example.
  • Keep register_post_meta() and show_in_rest on if a headless front end will read this type.
  • Match [supports] to what editors actually need; enabling everything clutters the editor.
  • Use the [meta_box_approach] consistently so sanitization and validation stay uniform across fields.
  • Add the PHPUnit tests for registration and REST endpoints early, since those break quietly after refactors.

Frequently Asked Questions

Is the custom post type exposed to the REST API?
Yes. The prompt registers `[cpt_name]` with `show_in_rest` enabled and uses `register_post_meta()` so meta fields appear in the API too. That makes the type usable by a headless front end or the block editor out of the box.
Does it handle data sanitization and security?
It adds sanitization callbacks like `sanitize_text_field`, `absint`, and `wp_kses_post`, and saves meta on the `save_post_{cpt_name}` hook with nonce verification and capability checks. These are the safeguards that keep untrusted input from reaching the database.
Can editors bulk-manage content with this system?
The admin list table gets `[column_count]` custom columns, taxonomy filter dropdowns, quick edit, and bulk actions for `[bulk_action]`. There is also an import/export tool handling `[import_format]` files for moving content in and out at scale.
Where do the templates live, in the theme or the plugin?
The archive and single templates ship from the plugin and load through the `[template_approach]`, so the post type works regardless of the active theme. This keeps the content type self-contained and portable across theme changes.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in WordPress & CMS Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support