How to Create a Custom Post Type in WordPress (With and Without a Plugin)

This guide covers “custom post type in wordpress” in plain language. A custom post type is a content type you define yourself, such as Books, Properties, Recipes or Team Members. WordPress comes with posts and pages, but real sites often need more structure. This guide shows two ways to create a custom post type: with a plugin and with code.

Why use a custom post type?

  • Separate content types. Keep portfolio items out of your blog feed.
  • Cleaner admin. Each type gets its own menu and editor.
  • Better templates. Display each type with its own layout.
  • Flexible data. Pair types with custom fields and taxonomies for rich content like listings or directories.

Method 1: Use a plugin

The easiest route needs no code.

  1. Install a post type plugin, such as Custom Post Type UI, and activate it.
  2. Go to the plugin’s Add/Edit Post Types screen.
  3. Enter a slug (lowercase, no spaces, such as book), plural and singular labels.
  4. Choose options like public visibility, archive support and which editor features to include.
  5. Save, and a new menu item appears in your dashboard.

Plugins are friendly and let you change settings later without editing files.

Method 2: Use code

Adding the type in code keeps it in your site’s files. Put this in a small plugin or your child theme’s functions.php:

add_action( 'init', function () {
    register_post_type( 'book', array(
        'labels' => array(
            'name'          => 'Books',
            'singular_name' => 'Book',
        ),
        'public'       => true,
        'has_archive'  => true,
        'show_in_rest' => true,
        'menu_icon'    => 'dashicons-book',
        'supports'     => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
        'rewrite'      => array( 'slug' => 'books' ),
    ) );
} );

Key options:

  • public makes the type visible on the front end and in the admin.
  • has_archive creates an archive page at /books/.
  • show_in_rest enables the block editor and REST API.
  • supports lists which editor features appear.
  • rewrite sets the URL structure.

After adding the code, go to Settings, then Permalinks and click Save to refresh rewrite rules. Without this step you may see 404 errors.

Where should the code live?

If you put the code in your theme, your post types vanish when you change themes. For content you want to keep, a small custom plugin is safer.

Display your custom post type

  • Archive page. With has_archive on, visit /books/ to see a listing.
  • Single page. Each entry has its own URL.
  • Custom templates. Create single-book.php and archive-book.php in your theme, or use a builder that supports custom templates and query loops.
  • Query on any page. Use WP_Query with 'post_type' => 'book' to list entries anywhere.

Add custom fields and categories

Most useful post types need extra data, such as price, author or ISBN. Custom field tools like ACF handle this without code. You can also register a custom taxonomy, for example a Genre for Books, to group entries.

Common mistakes on your custom post type in wordpress

  • Forgetting to flush permalinks after registering.
  • Using a slug that is too long (WordPress limits post type keys to 20 characters).
  • Using a slug that clashes with existing WordPress names.
  • Putting the registration inside the theme when you want the content to outlive it.

Custom post type in WordPress FAQ

Will a custom post type slow my site?

No. A post type is just another content type stored in the same database table.

Can I turn existing posts into a custom post type?

Yes. Plugins and WP-CLI can change the type of existing entries. Back up first.

Do custom post types appear in search?

If public is true and exclude_from_search is false, they appear in site search.

Related reading

Keep reading

Comparisons

The Best Elementor Alternative in 2026 (Clean Code, No Bloat)

Looking for an Elementor alternative that loads fast and doesn't lock you in? Here's what to look for, the top options, and why an AI-first, clean-code builder may be the upgrade you want.

Comparisons

The Best Lovable Alternative in 2026: WordPress + Tuli Builder

The best Lovable alternative for 2026: a full Lovable vs WordPress comparison on content, SEO, ownership and pricing — and why WordPress + Tuli is the $49-once answer to monthly fees.

Tutorials

How to Create a Cleaning Service Website With AI (Step-by-Step Guide)

Build a house or office cleaning service website with AI: service packages, instant quote forms, trust signals, recurring bookings and local SEO.

Tutorials

How to Create a Dance Studio Website With AI (Step-by-Step Guide)

Build a dance studio website with AI: class schedules, styles and ages, registration, recital info, instructor profiles and local SEO.

Tutorials

From ChatGPT to WordPress: Turn AI-Generated HTML Into a Real Site

Vibe-coded a site with ChatGPT or Claude? Here's how to go from ChatGPT to WordPress the right way — turning AI-generated HTML/CSS/JS into fully editable, dynamic WordPress pages.

Tutorials

How to Create a Pet Grooming Website With AI (Step-by-Step Guide)

Build a pet grooming or dog grooming website with AI: service menu by size, before and after photos, booking requests and local SEO.

Browse by topic: Tutorials · Comparisons · AI Website Building · Website guides by industry