@MWP\WordPress\PostType( name="customtype" )
This annotation will register a new post type to WordPress using the values provided in your property or method. Your post type will be registered with the core WordPress function register_post_type()
.
@Params
name="customtype"
(required) – The name of your post type
@Example Code
/**
* Custom Post Type
*
* @MWP\WordPress\PostType( name="custompost" )
*
* @var array
*/
public $myPostType = array
(
'labels' => array( 'name' => 'Custom Posts', 'singular_name' => 'Custom Post' ),
'public' => true,
'has_archive' => false,
'supports' => array( 'title', 'editor', 'comments', 'post-templates', 'thumbnail' ),
);
As A Method
This annotation can also be used on a method and the return value of that method will be used for the post type attributes
/**
* Custom Post Type
*
* @MWP\WordPress\PostType( name="custompost" )
*
* @var array
*/
public function myPostType()
{
return array
(
'labels' => array( 'name' => 'Custom Posts', 'singular_name' => 'Custom Post' ),
'public' => true,
'has_archive' => false,
'supports' => array( 'title', 'editor', 'comments', 'post-templates', 'thumbnail' ),
);
}