=== Dynamic CPT Generator ===
Contributors: nancyarora3193, pallavilimbasiya16
Tags: custom post type, custom fields, post type generator, post type builder, shortcode, grid, carousel, gutenberg block, dynamic post type, custom content type
Requires at least: 5.7
Stable tag: 3.0.0
Tested up to: 7.1
Requires PHP: 7.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Create custom post types with your own custom fields in one click, and display them with a shortcode or block — List, Grid, or Carousel layout.

== Description ==

**Dynamic CPT Generator** is a free, lightweight plugin that lets you create as many custom post types as you need, directly from a simple settings screen — no code, no config files, no developer required.

Every custom post type you create comes with its own shortcode, ready to drop into any post, page, or widget to display your content in a polished **List**, **Grid**, or **Carousel** layout.

= Why use Dynamic CPT Generator? =

* **One-click creation** — type a name, pick a layout, click Create. Your custom post type is registered instantly, complete with its own admin menu, categories, and tags.
* **Custom Field Builder** — add your own Text, Textarea, Number, URL, or Image fields to any custom post type, no code required. Fields show up as a metabox on the edit screen and automatically appear in the frontend display.
* **Three built-in display layouts** — List, Grid, and a touch-friendly Carousel (powered by Slick Slider), switchable at any time without touching code.
* **Shortcode-based output** — `[dcptg_display_dynamic_cpt type="yourchosenname"]` works anywhere shortcodes are supported, with optional `posts_per_page`, `orderby`, `order`, and `category` attributes.
* **Gutenberg block** — add a "Dynamic CPT Display" block from the block inserter and configure it visually, no shortcode typing required.
* **Built-in pagination** — set `posts_per_page` and visitors get automatic page-number navigation instead of one long list.
* **Built-in Read More toggle** — visitors can expand full content inline without leaving the page.
* **Categories & tags support** — every generated post type supports standard taxonomies out of the box.
* **Lightweight & conditional loading** — styles and scripts only load on pages that actually use the shortcode or block, keeping your site fast.
* **Safe cleanup** — manage or permanently delete a custom post type (and its posts) right from the settings screen.

= Common use cases =

Dynamic CPT Generator is a popular choice for building:

* Portfolios and project showcases
* Team member / staff directories
* Testimonials and reviews
* Products or services listings
* Events and announcements
* FAQs, case studies, and resource libraries

Use this shortcode anywhere on your site to display a custom post type:

`[dcptg_display_dynamic_cpt type="yourchosenname"]`

Or filter and paginate the results:

`[dcptg_display_dynamic_cpt type="yourchosenname" posts_per_page="6" category="news" order="ASC"]`

= Customizing the design =

Every layout is built from plain, documented CSS classes, so you can restyle the output to match your site by adding CSS in **Appearance > Customize > Additional CSS** (or your theme's stylesheet) — no plugin files need editing, and your changes survive plugin updates.

Container classes (one per layout, added to the shortcode/block wrapper):

* `.dcp-cpt-list` &mdash; List layout
* `.dcp-cpt-grid` &mdash; Grid layout
* `.dcp-cpt-carousel` &mdash; Carousel layout

Classes inside every item, regardless of layout:

* `.dcp-cpt-item` &mdash; the card/row wrapper for a single post
* `.dcp-cpt-item img` &mdash; the featured image (`.dcp-no-image` is added when a post has no featured image)
* `.dcp-excerpt` &mdash; the excerpt text
* `.dcp-full-content` &mdash; the full content revealed by "Read More"
* `.dcp-read-more` &mdash; the Read More / Show Less toggle link
* `.dcp-cpt-fields` &mdash; the list of custom field values (if the post type has any)
* `.dcp-cpt-pagination` &mdash; the pagination links (shown when `posts_per_page` is set)

Example — make grid cards use your brand color for the Read More button:

`.dcp-cpt-grid .dcp-read-more { background: #111 !important; }`

= Building your own layout (Custom) =

Need full control over the markup instead of just CSS? Pick **Custom** as the layout for any post type, then open "Custom Template" in the settings screen and write your own HTML using these placeholders — no PHP required:

* `{title}`, `{permalink}`, `{excerpt}`, `{content}` &mdash; the post's own data
* `{image}` &mdash; a ready-to-use `<img>` tag (or the built-in placeholder if there's no featured image); `{image_url}` gives you just the URL if you want to build your own `<img>` tag
* `{categories}`, `{tags}` &mdash; linked term lists
* `{fields}` &mdash; every custom field for this post type, pre-formatted as a list
* `{field:key}` &mdash; a single custom field's value on its own (replace `key` with the field's name, lowercased)

Example template:

`<div class="my-card">{image}<h3>{title}</h3><p>{excerpt}</p><span>{field:price}</span></div>`

If a post type is set to Custom but no template has been saved yet, the plugin automatically falls back to its default card layout, so output is never broken.

== Installation ==

1. Go to **Plugins > Add New** in your WordPress dashboard.
2. Search for **Dynamic CPT Generator**.
3. Click **Install Now**, then click **Activate**.
4. From the dashboard, go to **DCP CPT Generator**.
5. Enter a name for your custom post type (lowercase letters, numbers, and underscores only).
6. Choose a layout: **List**, **Grid**, or **Carousel**.
7. Click **Create**.
8. Use the shortcode `[dcptg_display_dynamic_cpt type="yourchosenname"]` to display your content.

== Frequently Asked Questions ==

= Does this work with any WordPress theme? =

Yes. Dynamic CPT Generator ships with its own self-contained styling for all three layouts, so it works independently of your active theme. You're also free to override the included CSS classes to match your site.

= Can I create more than one custom post type? =

Yes, there's no limit. Each one gets its own unique name, admin menu, and shortcode.

= Will deleting a custom post type delete my content? =

Deleting a custom post type from the settings screen permanently deletes all posts created under it. You'll be asked to confirm before anything is removed.

= Can I change the layout after creating a custom post type? =

Yes. Use the "Update Layout" control next to any registered post type to switch between List, Grid, and Carousel at any time — no need to recreate it.

= Does the plugin slow down my site? =

No. Carousel/List/Grid assets are only loaded on pages where the shortcode is actually used, not site-wide.

= Does it support categories and tags? =

Yes, every custom post type created with this plugin supports standard WordPress categories and tags.

= Can I add custom fields to a post type? =

Yes. Open "Manage Fields" under any registered post type and add Text, Textarea, Number, URL, or Image fields. They'll appear as a metabox when editing posts of that type, and automatically show up in the frontend output.

= Can I limit how many posts are shown, or paginate them? =

Yes, use the `posts_per_page` shortcode attribute (or the block's "Posts Per Page" setting). When set, page-number navigation is added automatically.

= Do I need to use the shortcode, or is there a block? =

Both are supported. Use the shortcode anywhere, or add the "Dynamic CPT Display" block from the block inserter in the editor for a visual, no-code setup.

== Screenshots ==

1. Plugin settings page for creating a custom post type.
2. List layout preview on the frontend.
3. Grid layout preview on the frontend.
4. Carousel layout preview on the frontend.

== Changelog ==

= 3.0.0 =
* Added: "Custom" layout option — write your own HTML template per post type using placeholders like `{title}`, `{image}`, `{fields}`, and `{field:key}`.
* Improved: Settings screen's own menu icon is now visually distinct from the icon used by each generated post type.

= 2.2.0 =
* Added: Custom Field Builder — add Text, Textarea, Number, URL, or Image fields to any custom post type, editable from a metabox and shown automatically on the frontend.
* Added: New shortcode attributes `posts_per_page`, `orderby`, `order`, and `category` for filtering output.
* Added: Automatic pagination when `posts_per_page` is set.
* Added: "Dynamic CPT Display" Gutenberg block as a visual alternative to the shortcode.

= 2.1.0 =
* Added: Placeholder image for posts without a featured image.
* Improved: Modernized admin settings screen with clearer sections, badges, and an empty-state message.
* Improved: Styles and scripts now load only on pages that use the shortcode, instead of site-wide.
* Fixed: Added nonce verification to the Delete and Update Layout actions.
* Fixed: Custom post type names are now validated against WordPress's naming rules and checked against reserved/core post type names.
* Added: Clean-up of stored settings and generated posts on uninstall.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 2.3.0 =
Adds a Custom layout option for full template control via placeholders. No breaking changes.

= 2.2.0 =
Adds a custom field builder, shortcode filtering/pagination, and a Gutenberg block. No breaking changes — existing shortcodes and post types keep working as-is.

= 2.1.0 =
Includes security fixes (nonce verification on admin actions) and performance improvements (conditional asset loading). Recommended for all users.
