Voxfor - All rights reserved - 2013-2025
We Accepted





WordPress comes with built-in “post” and “page” content types. Custom Post Types (CPTs) let you create entirely new content types for your site โ for example, a Book, Movie, Portfolio, or Testimonials section. As the WordPress documentation explains, the core Post API allows developers to register new post types stored in the database, and WordPress will automatically generate an admin menu and UI to manage them. In other words, once set up, your custom type appears in the dashboard like a normal section (just like Posts and Pages).
Custom Post Types are great for storing data objects other than posts and pages. For beginners, there are two main ways to create a CPT in WordPress: without a plugin (by writing a small bit of code) or with a plugin (Advanced Custom Fields (ACF)). Below, we cover both approaches in detail.
To create a CPT without a plugin, you add some code to your theme functions.php file or a custom plugin. The key function is register_post_type(), which tells WordPress about the new type. Important steps include:
Hook into init. WordPress documentation warns that post types must be registered during the init action, not too early. In practice, that means you write an init hook. For example, WordPress own docs show code like:
add_action('init', 'my_cpt_init');
function my_cpt_init() {
register_post_type( /* ... */ );
}
Define labels and arguments. Inside your function, call register_post_type( $key, $args ). The $key is a short, unique slug (lowercase, no spaces). The $args array defines how the CPT behaves. At minimum, you give it labels (for plural and singular names) and a few settings. For example:
function my_book_post_type() {
$args = array(
'labels' => array(
'name' => 'Books',
'singular_name' => 'Book'
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true
);
register_post_type('book', $args);
}
add_action('init', 'my_book_post_type');
Putting it all together, your code might be:
function my_portfolio_post_type() {
$args = array(
'labels' => array(
'name' => 'Portfolios',
'singular_name' => 'Portfolio'
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('portfolio', $args);
}
add_action('init', 'my_portfolio_post_type');
This code (in a plugin or your theme functions.php) creates a Portfolio section where you can add โportfolioโ posts in the admin menu. You can replace ‘portfolio’ and labels with your content type and names. Remember, each CPT key should be unique and under 20 characters (lowercase, underscores/dashes only). For more arguments and details, refer to the WordPress Codex or developer handbook on register_post_type().
For beginners who prefer a graphical interface, the Advanced Custom Fields (ACF) plugin (free or Pro) can register custom post types without coding. ACF adds a “Post Types” menu under the Custom Fields (ACF) menu in the WordPress admin. The steps are:
Using ACF means no PHP code is needed to register the type. You manage it entirely through the plugin’s interface. The screenshot above illustrates the ACF form; you simply enter names and select options, then save. If you later want to disable or remove the CPT, you can deactivate it in ACF (or delete the field group).
Note: Advanced Custom Fields primarily manages fields, but it includes the Post Types feature for ease of setup. You can think of the ACF CPT screen as a user-friendly front end for register_post_type(). Once you publish, WordPress treats the type just like if you had coded it. For example, you can go to Appearance โ Menus to add the new CPT archive link to a menu, or create theme templates like single-portfolio.php for custom display.
In summary, WordPress lets you create custom post types either by writing code or by using a plugin interface:
Both methods create identical “custom post types” in WordPress. Which you choose depends on your comfort level: coding gives more flexibility, while ACF provides simplicity. Once created, your custom post type will appear in the admin menu and can be filled with content just like posts or pages. You can then display that content on the front end with templates or shortcodes as needed.
Code What you want to present and organize your content in WordPress can be done with custom post types, whether you want to use code or use ACF. For beginners, using ACF is an easy way to get started without worrying about syntax, while learning the manual method helps you understand how things work under the hood.
Hassan Tahir wrote this article, drawing on his experience to clarify WordPress concepts and enhance developer understanding. Through his work, he aims to help both beginners and professionals refine their skills and tackle WordPress projects with greater confidence.