The functions add_menu_page
and add_submenu_page
are just like that, if you want to fill out that question you will have to customize everything from the <h2>Insira um artigo</h2>
.
But what you seek are Types of Custom Posts. The following code creates a TPP. Remarks:
- the domain
meu-tpp
is used for translation, check the documentation Translating Wordpress. But if you want you can remove all functions __()
and _x()
leaving the strings clean.
- also check the various parameters that can be used in
register_post_type
, especially in the array 'supports' => array( 'title', 'editor', etcetera )
.
- to further customize the TPP, we will use Custom Meta Boxes, which can be registered in the option
register_meta_box_cb
(disabled in the example below). See a example in the OS.
add_action( 'init', 'criar_artigos_sopt_9881' );
function criar_artigos_sopt_9881()
{
$labels = array(
'name' => _x( 'Artigos', 'post type general name', 'meu-tpp' ),
'singular_name' => _x( 'Artigo', 'post type singular name', 'meu-tpp' ),
'add_new' => _x( 'Add New', 'artigo', 'meu-tpp' ),
'add_new_item' => __( 'Add New Artigo', 'meu-tpp' ),
'edit_item' => __( 'Edit Artigo', 'meu-tpp' ),
'new_item' => __( 'New Artigo', 'meu-tpp' ),
'all_items' => __( 'All Artigos', 'meu-tpp' ),
'view_item' => __( 'View Artigo', 'meu-tpp' ),
'search_items' => __( 'Search Artigos', 'meu-tpp' ),
'not_found' => __( 'No artigos found', 'meu-tpp' ),
'not_found_in_trash' => __( 'No artigos found in Trash', 'meu-tpp' ),
'parent_item_colon' => '',
'menu_name' => __( 'Artigos', 'meu-tpp' )
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => _x( 'artigo', 'URL slug', 'meu-tpp' ) ),
'capability_type' => 'page',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'taxonomies' => array('category'),
'supports' => array( 'title', 'editor', 'comments', 'custom-fields', 'thumbnail' ),
//'register_meta_box_cb' => 'my_meta_boxes'
);
register_post_type( 'artigo', $args );
}
Thank you, it worked perfect.
– Bruno Martins