Create menus in the WordPress Dashboard

2

I need to create custom menus for a WordPress theme and I got to this function that works in parts, as it does not appear in the TITLE part and "TEXT" strong> or "SIDERBARS" , can you tell me where I'm wrong?

// Function para novos menus
function theme_options_panel(){
   add_menu_page(
       'Theme page title', 
       'Artigos', 
       'manage_options', 
       'theme-options', 
       'wps_theme_func'
   );
}

add_action('admin_menu', 'theme_options_panel');

function wps_theme_func(){
    echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
    <h2>Insira um artigo</h2></div>';
}

This is what happens:

    
asked by anonymous 20.03.2014 / 03:33

1 answer

2

The functions add_menu_page and add_submenu_page are anyway, if you want to fill that question you will have to customize everything from <h2>Insira um artigo</h2> .

But what you are looking for are Types of Personalized Posts . The following code creates a TPP. Remarks:

  • meu-tpp domain is used for translation, check out Translating WordPress documentation. But if you want you can remove all functions __() and _x() by leaving the strings clean.
  • Also check out the various parameters that can be used in register_post_type , especially in the 'supports' => array( 'title', 'editor', etcetera ) array.
  • To further customize TPP, we'll use Custom Meta Boxes , which can be registered in the register_meta_box_cb option (disabled in the example below). See an 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 );
}

    
20.03.2014 / 13:40