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

Tutorials

How to Build a WordPress Website With AI in 2026 (No Code Needed)

A practical, no-code guide to build a WordPress website with AI in 2026: describe your site in any language, let AI generate designed sections and copy, refine visually, and publish — in hours, not weeks.

Tutorials

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

Build a tree service or arborist website with AI: service pages, storm cleanup, certifications, project photos, quote forms and local SEO.

Tutorials

How to Create a Wedding Planner Website With AI (Step-by-Step Guide)

Build a wedding planner website with AI: portfolio of real weddings, packages, inquiry forms, testimonials and local SEO.

Tutorials

What Is Schema Markup? A Beginner’s Guide to Structured Data (2026)

What schema markup is, why it matters for SEO, the most useful types for small businesses and how to add structured data in WordPress.

Comparisons

The Best Bricks Builder Alternative in 2026 (AI Built In, Pay Once)

Looking for a Bricks Builder alternative? See how Tuli Builder compares on AI, clean code, lock-in, query loops and price, and who should stay with Bricks.

AI Website Building

Can ChatGPT Build a WordPress Website? What Works in 2026

Can ChatGPT build a WordPress website? It can write the pages, but not publish or make them editable. Here's how to turn ChatGPT's code into a real site.

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