{"id":1943,"date":"2023-06-29T10:00:00","date_gmt":"2023-06-29T15:00:00","guid":{"rendered":"http:\/\/racmanuel.dev\/?p=1943"},"modified":"2023-06-27T10:50:16","modified_gmt":"2023-06-27T15:50:16","slug":"como-crear-custom-post-types-sin-plugins-en-wordpress","status":"publish","type":"post","link":"https:\/\/racmanuel.dev\/en\/como-crear-custom-post-types-sin-plugins-en-wordpress\/","title":{"rendered":"How to create custom post types without plugins in WordPress"},"content":{"rendered":"<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" src=\"http:\/\/racmanuel.dev\/wp-content\/uploads\/pexels-photo-3861972-1024x683.jpeg\" alt=\"female software engineer coding on computer\" class=\"wp-image-2295\" title=\"\"><figcaption class=\"wp-element-caption\">Photo by ThisIsEngineering on <a href=\"https:\/\/www.pexels.com\/photo\/female-software-engineer-coding-on-computer-3861972\/\" rel=\"nofollow noopener\" target=\"_blank\">Pexels.com<\/a><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-1-agregar-el-codigo-en-el-archivo-functions-php\">Step 1: Add the code to the functions.php file<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The first thing we need to do is add the necessary code to the <code>functions.php<\/code> file of our WordPress theme. Open the file <code>functions.php<\/code> and add the following code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">function crear_custom_post_type() {\n\n  $labels = array(\n    'name' =&gt; 'Mis Custom Post Types',\n    'singular_name' =&gt; 'Mi Custom Post Type',\n    'menu_name' =&gt; 'Mis Custom Post Types',\n    'parent_item_colon' =&gt; 'Custom Post Type Padre:',\n    'all_items' =&gt; 'Todos los Custom Post Types',\n    'view_item' =&gt; 'Ver Custom Post Type',\n    'add_new_item' =&gt; 'Agregar Nuevo Custom Post Type',\n    'add_new' =&gt; 'Agregar Nuevo',\n    'edit_item' =&gt; 'Editar Custom Post Type',\n    'update_item' =&gt; 'Actualizar Custom Post Type',\n    'search_items' =&gt; 'Buscar Custom Post Type',\n    'not_found' =&gt; 'No se encontr\u00f3 ning\u00fan Custom Post Type',\n    'not_found_in_trash' =&gt; 'No se encontr\u00f3 ning\u00fan Custom Post Type en la papelera',\n  );\n\n  $args = array(\n    'label' =&gt; 'Mis Custom Post Types',\n    'description' =&gt; 'Custom Post Types personalizados para mi sitio web',\n    'labels' =&gt; $labels,\n    'supports' =&gt; array('title', 'editor', 'thumbnail', 'excerpt'),\n    'public' =&gt; true,\n    'has_archive' =&gt; true,\n    'menu_position' =&gt; 5,\n    'rewrite' =&gt; array('slug' =&gt; 'mis-custom-post-types'),\n    'show_in_rest' =&gt; true,\n  );\n\n  register_post_type('mis_custom_post_types', $args);\n\n}\n\nadd_action('init', 'crear_custom_post_type');<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this code, we are creating a Custom Post Type named \u201cMis Custom Post Types\u201d. The arguments passed in the second parameter of the <code>register_post_type()<\/code> function allow us to customize the appearance and behavior of the Custom Post Type. Some of the arguments we use are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>label<\/code>: the name that will be displayed on the Custom Post Type editing page.<\/li>\n\n\n\n<li><code>description<\/code>: a brief description of the Custom Post Type.<\/li>\n\n\n\n<li><code>supports<\/code>: the types of fields that will be displayed on the Custom Post Type editing page.<\/li>\n\n\n\n<li><code>public<\/code>: whether or not the Custom Post Type will be displayed on the website.<\/li>\n\n\n\n<li><code>has_archive<\/code>: whether or not an archive will be created for the Custom Post Type.<\/li>\n\n\n\n<li><code>rewrite<\/code>: the slug that will be used for the URLs of the Custom Post Types.<\/li>\n\n\n\n<li><code>show_in_rest<\/code>: whether or not the Gutenberg block editor will be enabled for the Custom Post Type.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-2-verificar-el-custom-post-type\">Step 2: Verify the Custom Post Type<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once we have added the code to the <code>functions.php<\/code>, 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 \u201cMis Custom Post Types\u201d. If we click on this entry, we will see the Custom Post Type editing page, similar to the editing page for posts or pages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-3-personalizar-el-custom-post-type\">Step 3: Customize the Custom Post Type<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once we have created the Custom Post Type, we can customize it according to our needs. We can add custom fields using the <code>add_meta_box()<\/code>, function, create custom taxonomies using the <code>register_taxonomy()<\/code> function, and customize the template using specific template files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>functions.php<\/code> file of our WordPress theme, we can create and customize Custom Post Types without needing to install an additional plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"algunos-plugins-para-generar-custom-post-types\">Some plugins to generate Custom Post Types<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are several plugins that allow you to generate Custom Post Types easily and quickly in WordPress. Below, we recommend a few:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"color: var(--theme-palette-color-2, #25ff00);\" class=\"stk-highlight\"><a href=\"https:\/\/wordpress.org\/plugins\/custom-post-type-ui\/\" data-type=\"URL\" data-id=\"https:\/\/wordpress.org\/plugins\/custom-post-type-ui\/\" rel=\"nofollow noopener\" target=\"_blank\">Custom Post Type UI:<\/a><\/span> 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. <\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/toolset.com\/\" data-type=\"URL\" data-id=\"https:\/\/toolset.com\/\" rel=\"nofollow noopener\" target=\"_blank\">Toolset Types:<\/a> 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.<\/li>\n\n\n\n<li><a href=\"Pods:https:\/\/wordpress.org\/plugins\/pods\/\" data-type=\"URL\" data-id=\"Pods:https:\/\/wordpress.org\/plugins\/pods\/\">Pods:<\/a> 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.<\/li>\n\n\n\n<li><a href=\"https:\/\/wordpress.org\/plugins\/advanced-custom-fields\/\" data-type=\"URL\" data-id=\"https:\/\/wordpress.org\/plugins\/advanced-custom-fields\/\" rel=\"nofollow noopener\" target=\"_blank\">Advanced Custom Fields:<\/a> 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.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>functions.php<\/code> file of your WordPress theme.<\/p>\n\n\n<style><\/style><style><\/style>\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading has-large-font-size\" id=\"necesitas-ayuda-con-un-proyecto-web\">Do you need help with a web project?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Do you need help with a web project? Don&#039;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&#039;s talk about your web project!<\/p>\n\n\n<div class=\"wp-block-groundhogg-forms\">\n\t<div class=\"gh-form-wrapper\"><form method=\"post\" class=\"gh-form gh-form-v2\" target=\"_parent\" enctype=\"multipart\/form-data\" name=\"Formulario de Contacto\" id=\"gh-form-24\" data-id=\"24\" action=\"\"><div class=\"gh-form-fields\"><div class=\"gh-form-column col-1-of-2\"><label for=\"first_name\">Name <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><input type=\"text\" name=\"first_name\" id=\"first_name\" class=\"gh-input gh-first-name\" value=\"\" required><\/div><\/div><div class=\"gh-form-column col-1-of-2\"><label for=\"last_name\">Last name(s) <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><input type=\"text\" name=\"last_name\" id=\"last_name\" class=\"gh-input gh-last-name\" value=\"\" required><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"email\">Email <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><input type=\"email\" name=\"email\" id=\"email\" class=\"gh-input gh-email\" value=\"\" required><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"primary_phone\">Phone or WhatsApp <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><input type=\"tel\" name=\"primary_phone\" id=\"primary_phone\" class=\"gh-input\" value=\"\" required><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"nombre_de_tu_negocio_o_empresa\">Name of your Business or Company<\/label><div class=\"gh-form-input-field\"><input type=\"text\" name=\"nombre_de_tu_negocio_o_empresa\" id=\"nombre_de_tu_negocio_o_empresa\" class=\"gh-input\" value=\"\"\/><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"link_de_tu_pagina_web\">Link to your website<\/label><div class=\"gh-form-input-field\"><input type=\"url\" name=\"link_de_tu_pagina_web\" id=\"link_de_tu_pagina_web\" class=\"gh-input\" value=\"\" placeholder=\"If your business or company has a website, enter the link here.\"\/><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"question_type\">What kind of question do you have? <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><select name=\"question_type\" id=\"question_type\" class=\"gh-input\" required><option value=\"Cotizaci\u00f3n\">Price<\/option><option value=\"General\">General<\/option><option value=\"Soporte\">Medium<\/option><\/select><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"message\">Ask <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><textarea name=\"message\" id=\"message\" class=\"gh-input\" rows=\"7\" placeholder=\"Your question or doubt...\" type=\"text\" required><\/textarea><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><div class=\"consent gh-gdpr\" id=\"gdpr_consent\"><div ><label class=\"gh-checkbox-label\"><input type=\"checkbox\" name=\"data_processing_consent\" id=\"data-processing-consent\" class=\"\" value=\"yes\" required><span class=\"checkbox-label\">I agree to racmanuel.dev&#8217;s storage and processing of my personal data. <span class=\"required\">*<\/span><\/span><\/label><\/div><div ><label class=\"gh-checkbox-label\"><input type=\"checkbox\" name=\"marketing_consent\" id=\"marketing-consent\" class=\"\" value=\"yes\"\/><span class=\"checkbox-label\">I agree to receive marketing offers and updates from racmanuel.dev.<\/span><\/label><\/div><\/div><\/div><div class=\"gh-form-column col-1-of-3\"><button type=\"submit\" class=\"gh-submit gh-button primary\" value=\"\">Get in touch!<\/button><\/div><\/div><input type=\"hidden\" name=\"trp-form-language\" value=\"en\"\/><\/form><\/div><\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>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.<\/p>","protected":false},"author":1,"featured_media":2295,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","_glsr_average":0,"_glsr_ranking":0,"_glsr_reviews":0,"footnotes":""},"categories":[48],"tags":[42],"niveles":[],"class_list":["post-1943","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutoriales","tag-wordpress"],"blocksy_meta":[],"acf":[],"_links":{"self":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/1943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/comments?post=1943"}],"version-history":[{"count":3,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/1943\/revisions"}],"predecessor-version":[{"id":2297,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/1943\/revisions\/2297"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/media\/2295"}],"wp:attachment":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/media?parent=1943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/categories?post=1943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/tags?post=1943"},{"taxonomy":"niveles","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/niveles?post=1943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}