plugins - Add a subitem to Woocommerce section

I want to add a subitem to "Woocommerce" parent item, below "Orders", this subitem is a custom post

I want to add a subitem to "Woocommerce" parent item, below "Orders", this subitem is a custom post type.

I tried to use (in $args):

$args = array('show_in_menu' => 'edit.php?post_type=shop_order');
register_post_type('my_posttype', $args);

But it doesn't work, I tried with another section ex. 'edit.php?anotherpage' and it works.

Any idea?!

I want to add a subitem to "Woocommerce" parent item, below "Orders", this subitem is a custom post type.

I tried to use (in $args):

$args = array('show_in_menu' => 'edit.php?post_type=shop_order');
register_post_type('my_posttype', $args);

But it doesn't work, I tried with another section ex. 'edit.php?anotherpage' and it works.

Any idea?!

Share Improve this question asked Jun 4, 2013 at 2:30 jepserjepser 4532 gold badges9 silver badges21 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 20

Short answer, use:

$args = array('show_in_menu' => 'woocommerce');
register_post_type('my_posttype', $args);

But this won't give you the custom post type submenus.

You can also use add_submenu_page, the code below is just an example:

function register_my_custom_submenu_page() {
    add_submenu_page( 'woocommerce', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' ); 
}
function my_custom_submenu_page_callback() {
    echo '<h3>My Custom Submenu Page</h3>';
}
add_action('admin_menu', 'register_my_custom_submenu_page',99);

You need a high(er) priority number to execute it later then the woocommerce_admin_menu function, which has 9, and there is woocommerce_admin_menu_after, which has 50 - those functionbs are in woocommerce-admin-init.php.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745581582a4634285.html

相关推荐

  • plugins - Add a subitem to Woocommerce section

    I want to add a subitem to "Woocommerce" parent item, below "Orders", this subitem is a custom post

    2天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信