-
Notifications
You must be signed in to change notification settings - Fork 0
Post Type
rogertm edited this page Jun 20, 2025
·
5 revisions
Para crear nuevos post types debemos crear una clase extendida de WASP\Posts\Post_Type.
- [create:post_type|CommandCreatePostType]
php cli/wasp create:post_type "Book"<?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.
- Function
register_post_type().