Skip to content

Post Type

rogertm edited this page Jun 20, 2025 · 5 revisions

abstract class Post_Type

Para crear nuevos post types debemos crear una clase extendida de WASP\Posts\Post_Type.

Wasp Cli

php cli/wasp create:post_type "Book"

wasp/classes/post-type/class-wasp-post-type-book.php

<?php
namespace WASP\Post_Type;

use WASP\Posts\Post_Type;

class Post_Type_Book extends Post_Type
{
    public function __construct()
    {
        parent::__construct();

        // CPT slug
        $this->post_type = 'wasp-book';

        // CPT labels
        $this->labels = array(
            'name' => _x( 'Book', 'Post type general name', 'wasp' )
        );

        // CPT arguments
        $this->args = array(
            'public' => true
        );
    }
}

La propiedad labels hace referencia a $args['labels'] en la función register_post_type(), args al resto de los argumentos pasados a esta función.

Referencias

Clone this wiki locally