Monday, 26 Oct 2026

Exclusive resources and tools for web design and development experts

Explore
BiblioWeb

Biblioweb.es

All About Web Technology

  • Start
  • WordPress
    WordPress
    • All about WordPress26
    • Plugins de WordPress16
    • Desarrollo web y plugins15
    Rendimiento y seguridad
    • Hosting y rendimiento8
    • Ciberseguridad web7
    • Solución de errores5
    Negocio e IA
    • IA y automatización10
    • WooCommerce y tiendas online6
    Lo último
    Restaurant Menu Widget — WordPress Plugin27 Sep 2026JetStudio Bookings — WordPress Plugin27 Sep 2026SC Heatmap — WordPress Plugin27 Sep 2026
    Ver el blog completoHistorial de noticiasAbout usNewsletter semanal
  • Plugins de WordPress
    Fichas de plugins
    • WP Translate Master
    • Cart Tool Kit
    • SC Heatmap
    • JetStudio Bookings
    • Restaurant Menu Widget
    • WP SEO Pro
    • Rank Math SEO in 2026
    • WP Rocket
    • WPCode
    • AI Engine para WordPress
    Comparativas y guías
    • The best SEO plugins for WordPress
    • The best AI plugins for WordPress
    • The best booking plugins for WordPress
    • WordPress multiidioma
    • Cómo crear un formulario de contacto en WordPress
    • Stripe o PayPal
    Por temática
    • Plugins de WordPress16
    • WooCommerce y tiendas online6
    • Desarrollo web y plugins15
    • IA y automatización10
    • Hosting y rendimiento8
    BibliotecaPlugin Library

    Los plugins de WordPress que desarrollamos: qué hace cada uno, cómo se ve en acción y dónde conseguirlo.

    Entrar en la Pluginteca
    Toda la categoría Plugins de WordPressHerramientas gratis
  • Tools
    Herramientas gratis, sin registro y desde el navegador
    Generador de contraseñasContraseñas largas y aleatorias sin salir del navegador.Generador de QRCódigos QR en PNG de alta resolución, sin caducidad.Contador de palabrasPalabras, caracteres y tiempo de lectura en vivo.JSON FormatterFormatea, valida y localiza el error exacto.WebP ConverterPNG, JPG y PDF a WebP para que la web cargue…PDF a WebPCada página del PDF, en una imagen ligera.Comprobador de emailsSintaxis, correos temporales y registros MX.Compresor de vídeoBaja el peso del vídeo sin subirlo a ningún servidor.Vídeo a MP3Extrae el audio de un vídeo en un par de clics.Firmas de emailFirma en HTML lista para Gmail y Outlook.
    También te sirveHerramientas externas que merecen la pena

    DNS Checker, Query Monitor, Local WP y el resto del kit que usamos a diario, con para qué sirve cada una.

    Ver la selección
    Todas las herramientasPlugin LibraryRecíbelas por correo
  • Plugin Library
  • Español
  • English ✓
  • 🇨🇳 中文(简体)
  • Français
  • Deutsch
  • Italiano
Newsletter
  • WordPress
  • Plugins de WordPress
  • WooCommerce
  • IA para WordPress
  • Security
  • Herramientas gratis
  • See everything
BiblioWebBiblioWeb
Font ResizerAa
  • WordPress
  • Plugins
  • WooCommerce
  • Errores
  • Tools
Search
  • Start
  • WordPress
    • All about WordPress
    • WordPress Plugins
    • Web Development and Plugins
    • AI and Web Automation
    • WooCommerce
    • Hosting and Web Performance
    • Cybersecurity and Web Security
    • Web Error Resolution
  • Plugins de WordPress
    • Rank Math SEO
    • AI Engine
    • WP Rocket
    • WPCode
    • WP Translate Master
    • Cart Tool Kit
    • SC Heatmap
    • JetStudio Bookings
    • Restaurant Menu Widget
    • WP SEO Pro
  • Tools
    • Password Generator
    • QR Code Generator
    • Word Counter
    • JSON Formatter
    • Image to WebP Converter
    • Email Checker
    • Video Compressor for Web
    • Email Signature Generator
    • Video to MP3 Converter
    • PDF to WebP Converter
  • Plugin Library
  • Blog
    • Español
    • English ✓
    • 🇨🇳 中文(简体)
    • Français
    • Deutsch
    • Italiano
Síguenos
© 2026 BiblioWeb — All rights reserved.
Cover » Blog » Custom Post Types in WordPress: complete guide
Web Development and Plugins

Custom Post Types in WordPress: complete guide

Adrián Alcalá
Actualizado: 08/08/2026 21:10
By Adrián Alcalá
Share
15 min de lectura
Custom Post Types in WordPress: complete guide
SHARE

WordPress was born as a blogging platform, but it stopped being just that a long time ago: today it manages portfolios, real estate agencies, academies, business directories, and entire stores. The piece that makes this versatility possible are WordPress custom post types: personalized content types that coexist with posts and pages, but with their own name, their own fields, their own URLs, and their own section in the dashboard. If you have ever tried to manage "projects," "recipes," or "courses" using normal posts and categories, you know how quickly it turns into chaos. In this complete guide, you will learn exactly what a Custom Post Type (CPT) is, when it makes sense to create one and when not, how to register it with complete and correct PHP code, how to add your own taxonomies, how to display it in your theme, and what implications it has for SEO. By the end, you will be able to structure any project with the solidity of a professional developer.

Índice
What are WordPress custom post typesWhen to create a CPT (and when not to)How to register a custom post type with codeCustom taxonomies: classifying your new contentHow to display custom post types in your themeCustom fields: the data that completes the entrySEO and custom post types: what you should reviewFrequently Asked QuestionsConclusion

What are WordPress custom post types

In WordPress, all content is technically a "post": blog posts (post), pages (page), media library attachments (attachment), revisions, or navigation menus. All are saved in the same database table (wp_posts) and are distinguished by the value of the column post_type. A custom post type is nothing more than a new value in that column, registered by you, with its own rules: what features it supports (editor, featured image, excerpt), what it's called in the menu, what URL its elements have, and whether or not it appears in search results.

Classic examples where WordPress custom post types shine:

  • Portfolio: projects with image, client, and technology used.
  • Real Estate: properties with price, area, and location.
  • Academy: courses and lessons with duration and level.
  • Restaurant: dishes with allergens and price.
  • Events: with date, place, and capacity.

In fact, you already use them without knowing it: WooCommerce products are a CPT called product, and the forms of almost any plugin are also saved as their own content types.

When to create a CPT (and when not to)

The key question: is this content conceptually different from a blog post? If the answer is yes (it makes sense to list it separately, with its own archives and its own structure), it is a candidate for a CPT. If you only want to group posts by topic, the correct tools are the traditional categories and tags.

Situation Appropriate solution
Separate the blog by topics Categories
Product sheets, courses, properties… Custom Post Type
Mark posts with loose keywords Tags
Classify a CPT (genre of a book, area of a property) Custom taxonomy
Specific data for each item (price, date, ISBN) Custom fields (post meta)

Another prior decision: code or plugin? Plugins like Custom Post Type UI or Pods allow registering CPTs from the panel without writing PHP, and they are perfectly valid. In return, they create dependency: if the plugin is deactivated, the content is not deleted but disappears from the dashboard. Code registration, which we will see now, is lighter, more portable, and more controllable, and it's how all professional themes and plugins do it.

You Might Also Like

WordPress without coding: what you can build with no-code
How to choose the perfect theme to design your website in WordPress
What is a child theme in WordPress and how to create it
How to install and configure Yoast SEO in WordPress

How to register a custom post type with code

Everything revolves around one function: register_post_type(), which must be executed on the hook init. This is a complete and commented registration for a portfolio CPT, ready to use:

<?php
function biblioweb_registrar_cpt_proyecto() {
    $labels = array(
        'name'               => 'Proyectos',
        'singular_name'      => 'Proyecto',
        'menu_name'          => 'Porfolio',
        'add_new'            => 'Añadir nuevo',
        'add_new_item'       => 'Añadir nuevo proyecto',
        'edit_item'          => 'Editar proyecto',
        'new_item'           => 'Nuevo proyecto',
        'view_item'          => 'Ver proyecto',
        'search_items'       => 'Buscar proyectos',
        'not_found'          => 'No se han encontrado proyectos',
        'not_found_in_trash' => 'No hay proyectos en la papelera',
        'all_items'          => 'Todos los proyectos',
    );

    $args = array(
        'labels'       => $labels,
        'public'       => true,
        'has_archive'  => true,
        'menu_position'=> 20,
        'menu_icon'    => 'dashicons-portfolio',
        'rewrite'      => array( 'slug' => 'proyectos', 'with_front' => false ),
        'supports'     => array( 'title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'custom-fields' ),
        'show_in_rest' => true, // Necesario para el editor de bloques y la REST API.
        'taxonomies'   => array(),
    );

    register_post_type( 'proyecto', $args );
}
add_action( 'init', 'biblioweb_registrar_cpt_proyecto' );

Let's review the arguments that generate the most doubts:

  • public: in true, the CPT has its own URLs, appears on the dashboard, and is visible. For internal content (e.g., testimonials that are only shown embedded) it can be refined with publicly_queryable y exclude_from_search.
  • has_archive: creates the archive page in tudominio.com/proyectos/ with the list of all elements.
  • rewrite: defines the URL slug. with_front => false avoids inheriting prefixes from the permalink structure (like /blog/).
  • supports: which boxes appear in the editor. If your CPT doesn't need a text editor, remove it and the form will be cleaner.
  • show_in_rest: essential in true if you want to use Gutenberg with this CPT or consume it from the REST API.
  • menu_icon: any icon from the Dashicons library, or the path to your own SVG.

A critical warning: after registering or modifying a CPT, visit Settings → Permalinks and click "Save Changes". This action regenerates the rewrite rules; if you don't, the new URLs will return a 404 error and you'll waste a lot of time looking for a bug that isn't in your code.

Where to put it? In your own plugin or in a snippet manager like WPCode, which we analyze in depth here. Avoid the theme's functions.php: a CPT is functionality, not design, and should survive a theme change.

Custom taxonomies: classifying your new content

Standard categories and tags belong to posts. To classify a CPT, the correct way is to register custom taxonomies with register_taxonomy(). Continuing with the portfolio, let's create a "Project Type" taxonomy:

<?php
function biblioweb_registrar_taxonomia_tipo() {
    $labels = array(
        'name'          => 'Tipos de proyecto',
        'singular_name' => 'Tipo de proyecto',
        'search_items'  => 'Buscar tipos',
        'all_items'     => 'Todos los tipos',
        'edit_item'     => 'Editar tipo',
        'add_new_item'  => 'Añadir nuevo tipo',
    );

    register_taxonomy(
        'tipo_proyecto',
        array( 'proyecto' ),
        array(
            'labels'       => $labels,
            'hierarchical' => true, // true = como categorías; false = como etiquetas.
            'rewrite'      => array( 'slug' => 'tipo-proyecto' ),
            'show_in_rest' => true,
        )
    );
}
add_action( 'init', 'biblioweb_registrar_taxonomia_tipo' );

The parameter hierarchical decides the behavior: in true works like categories (with parent-child hierarchy and checkboxes); in false, like tags (free text). Each term automatically generates its own archive page: tudominio.com/tipo-proyecto/diseno-web/.

How to display custom post types in your theme

WordPress resolves the presentation using the template hierarchy. For our CPT proyecto will search, in this order:

  1. single-proyecto.php for the individual entry (if it doesn't exist, use single.php).
  2. archive-proyecto.php for the listing (if it doesn't exist, use archive.php and then index.php).
  3. taxonomy-tipo_proyecto.php for taxonomy archives.

If your theme is block-based or you use a page builder, you can usually assign templates to the CPT from its own interface. And for custom listings in any template or shortcode, the query is made with WP_Query:

<?php
$proyectos = new WP_Query( array(
    'post_type'      => 'proyecto',
    'posts_per_page' => 6,
    'tax_query'      => array(
        array(
            'taxonomy' => 'tipo_proyecto',
            'field'    => 'slug',
            'terms'    => 'diseno-web',
        ),
    ),
) );

if ( $proyectos->have_posts() ) :
    while ( $proyectos->have_posts() ) : $proyectos->the_post();
        the_title( '<h3>', '</h3>' );
        the_post_thumbnail( 'medium' );
    endwhile;
    wp_reset_postdata();
endif;

Never forget wp_reset_postdata() after a custom loop: restores the main query and avoids strange side effects on the rest of the page. The complete reference of all available arguments is in the official post types documentation from developer.wordpress.org.

Custom fields: the data that completes the entry

A CPT defines the "container," but specific data (price, client, delivery date) lives in custom fields (post meta). You can manage them in three ways: with the native custom fields box (spartan but functional), with code using register_post_meta() y get_post_meta(), or with specialized plugins like Advanced Custom Fields (ACF) or Meta Box, which generate comfortable editing interfaces with validation and advanced field types. For serious projects, the combination CPT by code + ACF for fields is probably the industry standard.

<?php
// Registrar un campo y exponerlo en la REST API:
register_post_meta( 'proyecto', 'cliente', array(
    'type'         => 'string',
    'single'       => true,
    'show_in_rest' => true,
    'sanitize_callback' => 'sanitize_text_field',
) );

// Leerlo en la plantilla:
$cliente = get_post_meta( get_the_ID(), 'cliente', true );

SEO and custom post types: what you should review

A well-planned CPT is a blessing for SEO: it generates clean archives, semantic URLs, and a clear structure. But it's worth reviewing four points:

  • Sitemap: check that your SEO plugin includes the new content type in the XML sitemap. Both Yoast and Rank Math, whose free version we analyzed, detect public CPTs and allow them to be activated or excluded by type.
  • Selective indexing: if the CPT is supporting content (testimonials, reusable blocks), mark it as non-indexable or directly register it with public => false.
  • Slug with intent: /proyectos/ says more than /cpt_portfolio/. The rewrite slug is an SEO decision, and changing it later implies redirections.
  • Content in the archive: the automatically generated archive page is usually a simple list; considering a page with its own introductory text can make a difference for positioning the main keyword of the content type.

Frequently Asked Questions

What happens to the content if I deactivate the plugin that registers the CPT?

Nothing is deleted: the elements remain in the database. They simply stop being displayed in the dashboard and their URLs return 404, because WordPress no longer recognizes that content type. When reactivating the registration (plugin or snippet), everything reappears intact. That's why it's important to keep the registration in something independent of the theme.

Custom post type or categories? I'm still not sure which to use

Use categories when you want to organize blog articles that share a format. Use a CPT when the content has its own nature: different fields, different template, and makes sense as an independent section of the website. A practical hint: if you find yourself wanting to hide those "posts" from the main blog, it's almost certain they should be a custom post type.

How many custom post types can I create?

There is no relevant technical limit: all share the table wp_posts and the cost of registering each type is minimal. The reasonable limit is organizational: if you go over six or eight types, check if some shouldn't actually be taxonomies or fields of the same type. Reserve names with a prefix (for example bw_proyecto) if you distribute your code, to avoid collisions with other plugins.

Why do my custom post types give a 404 error?

In 95% of cases, due to rewrite rules: WordPress has not yet "learned" the new URLs. Go to Settings → Permalinks and save without changing anything. If it persists, check that public be true, that the rewrite slug does not conflict with an existing page and that the registration is executed in the hook init on every load, not just on activation.

Conclusion

WordPress custom post types are the tool that turns a blog into a true custom CMS: portfolios, catalogs, directories, or academies, each content with its structure, its URLs, and its place in the dashboard. The professional recipe fits into three steps: register the type with register_post_type() in the hook init (and save permalinks), classify it with custom taxonomies using register_taxonomy(), and complete the entries with custom fields. From there, the template hierarchy and WP_Query give you total control over how everything is displayed. Start with a single real content type from your project, register it with code in your own snippet or plugin, and check in the dashboard what changes managing real "projects" instead of disguised posts. You, your clients, and Google will appreciate that structural clarity.

Share This Article
Email Copiar enlace Print
ByAdrián Alcalá
Síguele:
Adrián Alcalá es desarrollador WordPress y consultor SEO, autor del plugin WP Translate y creador de BiblioWeb. Desde aquí comparte guías, tutoriales y herramientas gratuitas para quienes crean, optimizan y posicionan páginas web. Lleva años ayudando a negocios de toda España a sacar el máximo partido a WordPress, y todo lo que publica está probado en proyectos reales.
Previous Article WordPress Shortcodes: what they are and how to create them WordPress Shortcodes: what they are and how to create your own
Next Article The WordPress REST API: what it is and how to use it The WordPress REST API: what it is and how to use it
Ilustración del plugin Restaurant Menu Widget: carta de restaurante con platos y precios editables en Elementor
Restaurant Menu Widget — WordPress Plugin
WordPress Plugins
Ilustración del plugin JetStudio Bookings: formulario de citas por pasos con calendario y bandeja de solicitudes
JetStudio Bookings — WordPress Plugin
WordPress Plugins
Ilustración del plugin SC Heatmap: mapa de calor de clics y scroll sobre una web, con los datos en tu servidor
SC Heatmap — WordPress Plugin
WordPress Plugins
Accesibilidad web en WordPress con IA
Accesibilidad web en WordPress: auditarla con IA en una tarde
AI & Web Automation

También te puede interesar

Connect Google Sheets with WordPress
Web Development and Plugins

How to connect Google Sheets with WordPress

24/08/2026
WordPress Shortcodes: what they are and how to create them
Web Development and Plugins

WordPress Shortcodes: what they are and how to create your own

08/08/2026
WordPress - Beyond the Basics: Unlock Yoast SEO's Hidden Tricks to Take Your WordPress to the Next Level (and
Web Development and Plugins

Advanced Yoast SEO tricks to improve your WordPress

28/09/2026
WordPress Plugins - Don't start without them The 5 Essential WordPress Plugins every beginner needs for a top-notch website
Web Development and Plugins

The 5 essential WordPress plugins for beginners

28/09/2026
Show More
  • Temas:
  • WordPress
  • WordPress Plugins
  • Web Development and Plugins
  • AI & Web Automation
  • Web Hosting & Performance
  • Cybersecurity and Web Security
  • WooCommerce
  • Troubleshooting web errors
BiblioWeb

Biblioweb.es

Web Technology News

Information you can trust: practical web technology guides and solutions — WordPress, plugins, cybersecurity, hosting, performance, and error troubleshooting.

RSS

Enlaces de interés

  • About us
  • Contact
  • Free tools
  • Plugin Library

Recibe nuestras nuevas guías de WordPress en tu correo. Suscríbete a la newsletter.

Legal

  • Legal Notice
  • Terms and Conditions
  • Cookies Policy
  • Privacy Policy

Últimas novedades

Ilustración del plugin Restaurant Menu Widget: carta de restaurante con platos y precios editables en Elementor

Restaurant Menu Widget — WordPress Plugin

27/09/2026
Continue reading
Ilustración del plugin JetStudio Bookings: formulario de citas por pasos con calendario y bandeja de solicitudes

JetStudio Bookings — WordPress Plugin

27/09/2026
Continue reading

© 2026 BiblioWeb — All rights reserved.

Gestionar consentimiento
Utilizamos tecnologías como las cookies para almacenar y/o acceder a la información del dispositivo. Lo hacemos para mejorar la experiencia de navegación y para mostrar anuncios (no) personalizados. El consentimiento a estas tecnologías nos permitirá procesar datos como el comportamiento de navegación o los ID's únicos en este sitio. No consentir o retirar el consentimiento, puede afectar negativamente a ciertas características y funciones.
Funcional Always active
El almacenamiento o acceso técnico es estrictamente necesario para el propósito legítimo de permitir el uso de un servicio específico explícitamente solicitado por el abonado o usuario, o con el único propósito de llevar a cabo la transmisión de una comunicación a través de una red de comunicaciones electrónicas.
Preferences
El almacenamiento o acceso técnico es necesario para la finalidad legítima de almacenar preferencias no solicitadas por el abonado o usuario.
Estadísticas
El almacenamiento o acceso técnico que es utilizado exclusivamente con fines estadísticos. El almacenamiento o acceso técnico que se utiliza exclusivamente con fines estadísticos anónimos. Sin un requerimiento, el cumplimiento voluntario por parte de tu proveedor de servicios de Internet, o los registros adicionales de un tercero, la información almacenada o recuperada sólo para este propósito no se puede utilizar para identificarte.
Marketing
El almacenamiento o acceso técnico es necesario para crear perfiles de usuario para enviar publicidad, o para rastrear al usuario en una web o en varias web con fines de marketing similares.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
Ver preferencias
  • {title}
  • {title}
  • {title}
Accede a BiblioWeb
Usuario o correo electrónico
Contraseña

¿Has olvidado tu contraseña?