-
Notifications
You must be signed in to change notification settings - Fork 9
PostType
namespace: WPKit\PostType
Wrapper class for register_post_type.
Register and configure a post type.
string $key - unique key;
string $singular_name - post type title (singular);
array $labels (optional) - array of post type labels;
Example:
$product_post_type = new PostType( 'product', __( 'Product' ) );
This example creates a post type named "Product". You do not need to describe all labels of post type, the WPKit will do it for you. But if, for any reason, you need to define certain labels, then you can easily do it:
$product_post_type = new PostType( 'product', __( 'Product' ), [
'menu_name' => __( 'Shop' ),
'add_new' => __( 'Add New Product' ),
] );
Registers support of certain feature(s) for a post type. See add_post_type_support.
Default: ['title', 'editor', 'thumbnail']
Set icon to be used for this menu or the name of the icon from the iconfont. Icon can be defined in 3 ways:
- Icon url, example "http://site.com/icons/product.png"
- Base64 encoded content of SVG icon, example
"data:image/svg+xml;base64,PD94bWwgbj..."
- Icon name, example 'dashicons-cart'. See dashicons
Attach MetaBox to post type.
Attach Taxonomy to post type.
Add custom column to posts listing table.
Example:
$product_post_type->add_column( 'Price', function( $column ) {
echo get_post_meta( get_the_ID(), 'price', true );
} );
Add thumbnail column to posts listing table.
Set automatic pluralization.
Default: true