WordPress is a highly versatile content management platform that allows us to create different types of content for our website. One of the most powerful resources is Custom Post Types, which enable us to create personalized content types for our site without needing to install a plugin. In this tutorial, we will learn how to create Custom Post Types without plugins in WordPress.

Step 1: Add the code to the functions.php file
The first thing we need to do is add the necessary code to the functions.php file of our WordPress theme. Open the file functions.php and add the following code:
function crear_custom_post_type() {
$labels = array(
'name' => 'Mis Custom Post Types',
'singular_name' => 'Mi Custom Post Type',
'menu_name' => 'Mis Custom Post Types',
'parent_item_colon' => 'Custom Post Type Padre:',
'all_items' => 'Todos los Custom Post Types',
'view_item' => 'Ver Custom Post Type',
'add_new_item' => 'Agregar Nuevo Custom Post Type',
'add_new' => 'Agregar Nuevo',
'edit_item' => 'Editar Custom Post Type',
'update_item' => 'Actualizar Custom Post Type',
'search_items' => 'Buscar Custom Post Type',
'not_found' => 'No se encontró ningún Custom Post Type',
'not_found_in_trash' => 'No se encontró ningún Custom Post Type en la papelera',
);
$args = array(
'label' => 'Mis Custom Post Types',
'description' => 'Custom Post Types personalizados para mi sitio web',
'labels' => $labels,
'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
'public' => true,
'has_archive' => true,
'menu_position' => 5,
'rewrite' => array('slug' => 'mis-custom-post-types'),
'show_in_rest' => true,
);
register_post_type('mis_custom_post_types', $args);
}
add_action('init', 'crear_custom_post_type');
In this code, we are creating a Custom Post Type named “Mis Custom Post Types”. The arguments passed in the second parameter of the register_post_type() function allow us to customize the appearance and behavior of the Custom Post Type. Some of the arguments we use are:
label: the name that will be displayed on the Custom Post Type editing page.description: a brief description of the Custom Post Type.supports: the types of fields that will be displayed on the Custom Post Type editing page.public: whether or not the Custom Post Type will be displayed on the website.has_archive: whether or not an archive will be created for the Custom Post Type.rewrite: the slug that will be used for the URLs of the Custom Post Types.show_in_rest: whether or not the Gutenberg block editor will be enabled for the Custom Post Type.
Step 2: Verify the Custom Post Type
Once we have added the code to the functions.php, file, we can verify whether the Custom Post Type has been created correctly. In the WordPress admin panel, we should see a new entry in the sidebar menu called “Mis Custom Post Types”. If we click on this entry, we will see the Custom Post Type editing page, similar to the editing page for posts or pages.
Step 3: Customize the Custom Post Type
Once we have created the Custom Post Type, we can customize it according to our needs. We can add custom fields using the add_meta_box(), function, create custom taxonomies using the register_taxonomy() function, and customize the template using specific template files.
Conclusion
In summary, we have learned how to create Custom Post Types without plugins in WordPress. Custom Post Types allow us to create personalized content types for our website and can be very useful for various purposes, such as events, testimonials, portfolios, and much more. By using the functions.php file of our WordPress theme, we can create and customize Custom Post Types without needing to install an additional plugin.
It is important to note that Custom Post Types are a very powerful feature of WordPress and can be used to create a wide variety of content on our website. The key is to customize them according to our needs and ensure that the functionality is consistent with the rest of our site.
It is also important to keep in mind that creating Custom Post Types can be a complex task and requires programming knowledge in PHP and WordPress. Therefore, if you are unsure how to do it, you may want to seek the help of an experienced WordPress developer.
In conclusion, we hope this tutorial has been helpful in learning how to create Custom Post Types without plugins in WordPress. Take advantage of this tool and create a personalized and attractive website for your visitors!
Some plugins to generate Custom Post Types
There are several plugins that allow you to generate Custom Post Types easily and quickly in WordPress. Below, we recommend a few:
- Custom Post Type UI: It is one of the most popular plugins for creating Custom Post Types in WordPress. With this tool, you can create and manage Custom Post Types and custom taxonomies from the WordPress admin panel.
- Toolset Types: This plugin allows you to create Custom Post Types, custom fields, and custom taxonomies without needing programming knowledge. It also includes a tool for customizing Custom Post Type templates.
- Pods: It is a free plugin that allows you to create Custom Post Types and custom fields in WordPress. It is also possible to create relationships between different Custom Post Types.
- Advanced Custom Fields: Although it is not a specific plugin for creating Custom Post Types, it is a very useful tool for adding custom fields to existing Custom Post Types. With this tool, you can add text, image, gallery, date, selection fields, and much more.
In general, these plugins are very useful for creating Custom Post Types easily and quickly, especially if you do not have programming knowledge in WordPress. However, if you are looking for a more customized solution, you may want to create your own Custom Post Types from scratch using the functions.php file of your WordPress theme.
Do you need help with a web project?
Do you need help with a web project? Don't hesitate to contact me. I develop complete and customized solutions with WordPress and PHP, using modern tools and processes, HTML, CSS, SCSS, PHP, JavaScript, Bootstrap, and more. Ready? Send me a message and let's talk about your web project!
