You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

1 Días
9 Hrs
28 Min
6 Seg

¿Qué es un Post Type?

20/35
Resources

What is a Custom Post Type in WordPress?

In WordPress, flexibility is crucial to adapt to different website needs. Sometimes, the default options such as posts and pages are not sufficient for the unique requirements of each project. This is where Custom Post Types come into play. Custom Post Types allow you to create custom content types that are perfectly suited to the specific characteristics of your site. For example, if you manage an online library and need to display books with ratings and authors, you can create a Custom Post Type called "Books".

Why use Custom Post Types in WordPress?

The use of Custom Post Types offers multiple benefits for those who manage WordPress websites:

  • Adaptability: you can create unique content structures that perfectly suit your site's needs without having to compromise with the limitations of default posts or pages.
  • Clarity in content management: By having well-defined content types, you avoid the confusion and visual clutter that could be generated by trying to force unnatural content into standard options.
  • Additional features: You can add custom fields that highlight specific attributes of the content, providing a richer and more targeted user experience.

How to create a Custom Post Type in WordPress?

Creating a Custom Post Type in WordPress is a process that involves certain technical steps, but they can be carried out effectively by following a clear guide. Here is a summary of how to do it:

  1. Access WordPress Files: Before you begin, make sure you have access to your WordPress files and a backup for safety.

  2. Register Custom Post Type: Use WordPress functions to register a new content type within your functions.php file or via a content type specific plugin. PHP code example:

    function create_custom_post_type() { $args = array( ' public' => true, ' label' => 'Books', ' supports' => array('title', 'editor', 'thumbnail'), ); register_post_type('books', $args);}add_action('init', 'create_custom_post_type');

    This code creates a Custom Post Type called "Books" that supports title, editor and thumbnails.

  3. Manage Custom Post Type features: Make sure to customize features and display options such as labels, categories, and admin menus to optimize usability and management.

How to display Custom Post Types in WordPress?

Once a Custom Post Type has been created, it is important to define how and where it will be displayed on your website. The good management and presentation of the content is key to the user experience:

  • Custom Templates: create specific templates within your WordPress theme to handle the unique presentation of your Custom Post Types. You can design templates for lists and individual content views.

  • Custom Queries: Use WordPress query functions to display your Custom Post Types in different parts of your site. For example:

    $args = array( ' post_type' => 'books', ' posts_per_page' => 10,);$books_query = new WP_Query($args);
  • Widgets and Shortcodes: Implement widgets or shortcodes to offer more flexibility and customization options in inserting your Custom Post Types in different pages and posts.

Custom Post Types are powerful tools to maximize the potential of your WordPress website. Take advantage of these techniques to not only improve the appearance and functionality of the site, but also to provide an optimized experience for visitors. Keep learning and exploring to master this resource and give more value to your web designs.

Contributions 11

Questions 2

Sort by:

Want to see more contributions, questions and answers from the community?

¿Qué es un Post Type?
Wordpress tiene muchos tipos de diferentes de contenido, a cada uno de estos tipos se los llama Post Type (Tipo de contenido).

PostType por defecto:

  • Entradas (Post)
  • **Páginas **(Page)
  • **Archivos multimedia **(Attachment)
  • **Menús **(Navigation Menus)

Custom Post Type
Si bien tenemos varios tipos de contenido por defecto en WordPress, podemos crear tipos de contenido que se adapten a nuestro proyecto. A estos se les llaman Custom Post Type. Ejempo: Post Type Libros, Discos, Clientes…

Aqui dejo un generador de post_types para wordpress, muy util cuando estamos creando/modificando nuestros temas.
https://generatewp.com/post-type/
De hecho se pueden generar diferentes tipos de contenidos

Post Types que vienen incluido en una instalación de WordPress

Posts: Es muy usado en blogs. Normalmente se muestran en un orden secuencial inverso ordenado por tiempo.
**Pages: **Similar al post, pero no se muestran en un orden inverso basado en el tiempo. Se pueden colocar en un orden jerarquico donde una pagina puede ser padre o hijo de otra pagina.
Attachments: Retiene información sobre cualquier medio de comunicación que es subido al sitio web.
Revisions: Se usa para crear un historial de otros post types en caso de que comentas un error y quierar regresar a una version anterior.
Menus: Son una lista de enlaces que pueden ser usados para navegar en el sitio web.
Custom CSS: Es usado para almacenar CSS guardado de la pantalla de Personalizar CSS Adicional.
Changesets: Similar a las revisiones, pero especificamente para el Personalizador. Est para mantener al Personalizador en un estado persistente.

Gracias por la clase. Perfectamente claro.

https://gwst.eu

¿Qué es un Post Type?
Wordpress tiene muchos tipos de diferentes de contenido, a cada uno de estos tipos se los llama Post Type (Tipo de contenido).

PostType por defecto:

Entradas (Post)
**Páginas **(Page)
**Archivos multimedia **(Attachment)
**Menús **(Navigation Menus)
Custom Post Type
Si bien tenemos varios tipos de contenido por defecto en WordPress, podemos crear tipos de contenido que se adapten a nuestro proyecto. A estos se les llaman Custom Post Type. Ejempo: Post Type Libros, Discos, Clientes…

Post Type

no se escucha el video

este curso repite practicamente todo de los cursos del nivel inicial.

Me aparece este error en mi página: Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\platzigift\wp-content\themes\platzigifts\functions.php on line 12
Ha habido un error crítico en tu web.

Aprende más sobre la depuración en WordPress.

<?php 

function init_template (){
    add_theme_support('post-thumbnails');
    add_theme_support( 'title-tag');

    register_nav_menus(
        array(
            'top_menu' => 'Menú Principal'
        )
    )
}

add_action('after_setup_theme','init_template');

function assets(){
    wp_register_style('bootstrap','https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css'
, '', '4.4.1', 'all');
wp_register_style('montserrat', 'https://fonts.googleapis.com/css?family=Montserrat&display=swap','','1.0', 'all');
wp_enqueue_style('estilos', get_stylesheet_uri(), array('bootstrap','montserrat'), '1.0', 'all');

wp_register_script('popper','https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js','','1.16.0', true);
wp_enqueue_script('bootstraps', 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js', array('jquery', 'popper'),'4.4.1', true);

wp_enqueue_script('custom', get_template_directory_uri().'/assets/custom/js', '', '1.0', true);

}

add_action('wp_enqueue_scripts','assets');

function sidebar(){
    register_sidebar(
        array(
            'name'=> 'Pie de pagina',
            'id' => 'footer',
            'description' => 'zona de Widgets para pie de página',
            'before_title' => '<p>',
            'after_title' => '</p>',
            'before_widget' => '<div id="%1$s" class="%2$s">'.
            'after_widget' => '</div>'
        )
    )
}

add_action('widgets_init',)```

Es lo mismo que en Drupal se llama content type

Orale…