Example of custom post type
My CPT base.
if ( ! function_exists('custom_post_type_hello_world') ) {
// Register Custom Post Type
function custom_post_type_hello_world() {
$labels = array(
'name' => _x( 'Hello World', 'Post Type General Name', 'omni' ),
'singular_name' => _x( 'Hello World', 'Post Type Singular Name', 'omni' ),
'menu_name' => __( 'Hello World', 'omni' ),
'name_admin_bar' => __( 'Hello World', 'omni' ),
'archives' => __( 'Hello World', 'omni' ),
'attributes' => __( 'Item Attributes', 'omni' ),
'parent_item_colon' => __( 'Item Pai:', 'omni' ),
'all_items' => __( 'Ver Todos', 'omni' ),
'add_new_item' => __( 'Novo Hello World', 'omni' ),
'add_new' => __( 'Novo Hello World', 'omni' ),
'new_item' => __( 'Novo Hello World', 'omni' ),
'edit_item' => __( 'Editar Hello World', 'omni' ),
'update_item' => __( 'Atualizar Hello World', 'omni' ),
'view_item' => __( 'Ver Hello World', 'omni' ),
'view_items' => __( 'View Items', 'omni' ),
'search_items' => __( 'Buscar Hello World', 'omni' ),
'not_found' => __( 'Nada Encontrado', 'omni' ),
'not_found_in_trash' => __( 'Nada na lixeira', 'omni' ),
'featured_image' => __( 'Imagem Destacada', 'omni' ),
'set_featured_image' => __( 'Definir Imagem Destacada', 'omni' ),
'remove_featured_image' => __( 'Remover Imagem Destacada', 'omni' ),
'use_featured_image' => __( 'Usar como imagem destacada', 'omni' ),
'insert_into_item' => __( 'Anexadas neste item', 'omni' ),
'uploaded_to_this_item' => __( 'Enviadas para este item', 'omni' ),
'items_list' => __( 'Lista de Itens', 'omni' ),
'items_list_navigation' => __( 'Navegar na lista de itens', 'omni' ),
'filter_items_list' => __( 'Filtrar lista de itens', 'omni' ),
);
$rewrite = array(
'slug' => 'hello-world',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$capabilities = array(
'edit_post' => 'edit_post',
'read_post' => 'read_post',
'delete_post' => 'delete_post',
'edit_posts' => 'edit_posts',
'edit_others_posts' => 'edit_others_posts',
'publish_posts' => 'publish_posts',
'read_private_posts' => 'read_private_posts',
);
$args = array(
'label' => __( 'Hello World', 'omni' ),
'description' => __( 'Example of Description of my post type', 'omni' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats' ),
'taxonomies' => array( 'category', ' post_tag' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-media-document',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'hello-world',
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capabilities' => $capabilities,
);
register_post_type( 'example', $args );
}
add_action( 'init', 'custom_post_type_hello_world', 0 );
}