Skip to main content
Monday, November 30, 2026 New tutorials published every day
Home
Free Tools
Typing Test New JSON Formatter Base64 Encoder / Decoder Password Generator Text to QR Code Generator Word Counter Case Converter Age Calculator Color Converter Number to Words All Free Tools
Projects
PHP Projects — all projects
Students
Webflow Course Course Registration Download Syllabus Verify Certificate Student Leaderboard
Resources
WordPress Plugins Search tutorials About CodingCush Contact
More
Login
WordPress

WordPress Custom Post Types Explained Simply for Beginners

WordPress custom post types explained simply: what they are, when to use one, and how to register a Recipes post type with code or a plugin, step by step.

A custom post type in WordPress is a new kind of content with its own admin menu and its own pages on your site. Posts are for blog articles and pages are for fixed content like About and Contact, but a custom post type stores a different kind, such as recipes or team members, in its own neat box. This tutorial shows you what one is, when you need one, and how to register one with a few lines of PHP.

Step 1: Understand What a Custom Post Type Is

WordPress ships with five built in post types: post, page, attachment, revision, and menu. Each one is a container for a different kind of content: a post appears in your blog feed, a page does not, and an attachment is a media file. A custom post type is just a sixth container that you define yourself.

Picture a food blog with two hundred recipes stored as normal posts, mixed in with news updates in the same category list. Give the blog a Recipes post type instead, and the recipes get their own admin menu and their own archive page at yoursite.com/recipes/. If WordPress itself is still new to you, read our guide to what WordPress is, explained simply first.

Step 2: Decide When You Actually Need One

Not every site needs one. Ask one question: does this content repeat with the same shape every time?

You need one when the shape repeats. A recipe always has a title, ingredients, and steps. A portfolio project always has a title, a screenshot, and a link. Events, products, and testimonials fit the same pattern.

You do not need one when a category or a tag would do the job. Ten travel stories are just posts in a Travel category. If the content will grow into a collection, give it its own post type. If it is a one off, do not.

Step 3: Register Your Post Type With Code

You register a post type with one WordPress function, register_post_type(), hooked to the init action. We will register a Recipes post type as our example. The official Registering Custom Post Types guide in the WordPress Plugin Handbook shows the same pattern.

The official docs recommend putting custom post types in a plugin rather than a theme, so your content stays portable if you change your theme later. If you are not sure how the two differ, read our guide to the difference between a WordPress theme and a plugin. Paste this into a tiny custom plugin:

function codingcush_register_recipe_post_type() {
    register_post_type( 'recipe', array(
        'labels'       => array(
            'name'          => __( 'Recipes', 'codingcush' ),
            'singular_name' => __( 'Recipe', 'codingcush' ),
        ),
        'public'       => true,
        'has_archive'  => true,
        'show_in_rest' => true,
        'menu_icon'    => 'dashicons-food',
        'supports'     => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
        'rewrite'      => array( 'slug' => 'recipes' ),
    ) );
}
add_action( 'init', 'codingcush_register_recipe_post_type' );

The function name is ours. register_post_type() takes a short key, 'recipe', and a list of settings. The key must be 20 characters or fewer, lowercase letters, numbers, dashes, and underscores only, and it must not be a reserved name like post, page, or attachment. The labels array sets the words shown in the admin area: Recipes in menus and Recipe on the single item screen. The __() function marks those words as translatable.

The next three settings control visibility. 'public' => true makes the post type visible on the front of the site and in the admin area. 'has_archive' => true gives it an archive page at yoursite.com/recipes/. 'show_in_rest' => true includes it in the REST API, which is what makes the modern block editor available. Skip that last one and you will be stuck with the old classic editor.

'menu_icon' => 'dashicons-food' picks the food icon for the admin menu. WordPress ships a set of icons called Dashicons, so you can swap in dashicons-book for books. 'supports' lists the editing features each recipe gets: a title box, the main editor, a featured image, and a short excerpt box. 'rewrite' sets the web address slug. The last line, add_action( 'init', ... ), runs our function on the init hook.

Save the file, make sure your plugin is active, and look for a new Recipes menu in your admin sidebar. Then go to Settings, then Permalinks, and click Save Changes once, so the new addresses work instead of showing a 404 page.

Post vs Page vs Custom Post Type

The three content kinds look alike in the editor, but they behave differently:

  Post Page Custom Post Type
Best for Blog articles and news Fixed content like About Repeating content like recipes
Shows in the blog feed Yes No No, unless you ask for it
Has its own archive page Yes, the blog page No Yes, if has_archive is true
Has its own admin menu Yes, Posts Yes, Pages Yes, named after your type
Parent and child items No Yes Only if hierarchical is true
Example address /hello-world/ /about/ /recipes/chocolate-cake/

Posts are time based and pages are fixed, while a custom post type is whatever collection your site needs.

Screenshot of the Registering Custom Post Types page in the WordPress Plugin Handbook on developer.wordpress.org, showing the five default post types and the recommendation to put custom post types in a plugin
The official Registering Custom Post Types page in the WordPress Plugin Handbook, the starting point for this tutorial.

Step 4: Make It Show on Your Site

Registering the post type is only half the job. Now check the menu, the archive page, and the single item page.

First, the menu. Go to Appearance, then Menus, and add the recipe archive to your menu.

Second, the archive page. Because we set has_archive to true, yoursite.com/recipes/ already lists every recipe. If it shows a 404 error, save your permalinks again.

Third, the single recipe page. WordPress looks for single-recipe.php in your theme and falls back to single.php. For archives the same idea applies: archive-recipe.php, then archive.php.

For a custom list of recipes, a small WP_Query loop does it. This example shows the six newest recipes:

$recipes = new WP_Query( array(
    'post_type'      => 'recipe',
    'posts_per_page' => 6,
) );

if ( $recipes->have_posts() ) {
    while ( $recipes->have_posts() ) {
        $recipes->the_post();
        the_title( '<h2>', '</h2>' );
        the_excerpt();
    }
    wp_reset_postdata();
}

WP_Query asks WordPress for items of the recipe type, six at a time. have_posts() checks whether any exist, the_post() loads each one, the_title() prints its title, and the_excerpt() prints its summary. wp_reset_postdata() restores the main page query afterwards. Every argument is documented on the official register_post_type() reference page.

Step 5: The Plugin Shortcut (No Code Needed)

If PHP is not your thing yet, you do not have to write a single line. Plugins like Custom Post Type UI register post types through a settings form: type the name and labels, tick the boxes, and it generates the registration for you.

The trade off is dependence: a form built post type works only while that plugin is active, while the code version is portable. Start with a plugin if you are in a hurry, then switch to the code version once the recipe example above makes sense. Either way, you will need to know how to install a WordPress plugin first.

Common Mistakes and How to Fix Them

The Recipes menu does not appear. Check that the plugin holding your code is active and the code is hooked to init. One missing comma stops the whole file.

Single recipes and the archive page show a 404 error. Go to Settings, then Permalinks, and press Save Changes.

The block editor is missing. Your post type is registered without 'show_in_rest' => true. Add that line and reload the editor.

Your content vanished after changing themes. Your post type was registered inside the old theme, and it left with the theme. The posts are still in the database, so move the code into a small plugin and reactivate it.

Questions Beginners Keep Asking

Do custom post types slow down WordPress?

No. Registering a post type adds a tiny amount of setup work when WordPress loads. Site speed depends on hosting, theme, and images.

Can I add categories to a custom post type?

Yes. Add 'taxonomies' => array( 'category', 'post_tag' ) to your settings.

Can I turn normal posts into a custom post type later?

There is no built in convert button. If a collection will grow, give it its own post type from the start.

Will my recipes disappear if I change my theme?

Only if it was registered in the theme. Put the registration in a plugin and your recipes will survive any theme change.

Your Next Steps

A custom post type sounds technical until you try it, and then it feels obvious: a named box for one kind of content, with its own menu, its own editor, and its own pages.

Your homework is small. Register the Recipes post type from Step 3, add three real recipes, and put the archive in your menu. Then open a single recipe and notice the address: /recipes/ followed by the recipe name.

Lavkush
Written by

Lavkush Super Admin

Lavkush Kumar is a software developer with over 6 years of experience turning ideas into websites and web applications. He holds a Master of Computer Applications (MCA) degree and enjoys building for the web, exploring new tools, and sharing what he learns along the way.

Through CodingCush, Lavkush creates easy-to-follow tutorials and practical guides to help students and beginners learn software development without feeling overwhelmed. His approach is simple: learn by doing, build real projects, and keep improving one step at a time.

Whether you’re just starting out or looking to sharpen your skills, CodingCush is all about making learning practical, beginner-friendly, and fun.

0 Comments

Leave a Comment