1

I want to know how to add a new submenu for a custom post type in creating a wordpress plugin. What I have done for now, I've created a custom post type called 'funds'.

add_action( 'init', 'wnm_add_funds' );
function  wnm_add_funds() {
register_post_type('wnm_funds',
    array(
        'labels'        => array(
                                'name'              => __( 'Funds' ),
                                'add_new'           => __( 'Add New Fund' ),
                                'add_new_item'      => __( 'Add New Fund' ),
                                'edit_item'         => __( 'Edit Fund' )),
        'public'        => true,
        'has_archive'   => true,
        'menu_position' => 100
    )
);

}

This code adds a custom post type called 'Funds' and under it is two submenus ('funds','add new fund'). What I would like to do is to add new submenu under funds. Example I would like to add 'Fund Settings', so under funds there will be (funds,add new fund,fund settings).

how would i do that?

4

1 回答 1

3

您可以这样做: http:
//codex.wordpress.org/Function_Reference/add_submenu_page
http://codex.wordpress.org/Roles_and_Capabilities
我不知道该功能是否适合您的原因,但这会起作用

<?php
add_submenu_page(
    'edit.php?post_type=wnm_funds',
    'Fund Settings', /*page title*/
    'Settings', /*menu title*/
    'manage_options', /*roles and capabiliyt needed*/
    'wnm_fund_set',
    'CALLBACK_FUNCTION_NAME' /*replace with your own function*/
);

要将设置/选项添加到页面,我推荐设置 API
一个很好的(而且有点长)教程如何使用它:http ://wp.tutsplus.com/tutorials/the-complete-guide-to-the-wordpress-设置-api-part-1/

于 2012-06-22T06:08:44.403 回答