Skip to content

CommandCreatePostType

rogertm edited this page Apr 8, 2026 · 2 revisions

$ php cli/wasp create:post_type

Descripción

Crea una clase de Custom Post Type usando stubs y la configuración actual.

Uso

create:post_type [options] [--] <name> [<project>]

Argumentos

  • name Nombre del CPT (ej: "Book").
  • project Slug del proyecto destino (ej: wasp-child). Si se omite, usa wasp.

Opciones

  • --dry-run Simula la creación sin escribir archivos.
  • -h, --help Muestra la ayuda.

Ejemplos

Plugin actual:

php cli/wasp create:post_type "Book"

En un child plugin:

php cli/wasp create:post_type "Book" "wasp-child"

Simulación:

php cli/wasp create:post_type "Book" --dry-run

Resultado esperado

  • Crea classes/post-type/class-{project}-post-type-book.php.
    • Ejemplo en WASP: wasp/classes/post-type/class-wasp-post-type-book.php
  • Agrega en inc/classes.php:
new {Namespace}\Post_Type\Post_Type_Book;

Fragmento de clase generada

class Post_Type_Book extends Post_Type
{
    public function __construct()
    {
        $this->post_type = 'wasp-book';
    }
}

Clone this wiki locally