Andy Tran

Add Sub Menu in Custom Post Type

by | 2 Sep, 2021 | Wordpress | 0 comments

create sub-menu in custom post type

Before you read how to add sub menu in custom post type menu it is most important, you understand
How to Add a Custom Post Type Without a Plugin. To visit the post and explore more about the post. Click here.

Add sub-menu in Custom Post Type

add_submenu_page() this function used to add submenu in Admin Menu Page. And You will remove submenu from wordpress admin using remove_submenu_page().

add_submenu_page() by default takes 7 parameters.

      string $parent_slug, 
      string $page_title, 
      string $menu_title, 
      string $capability, 
      string $menu_slug, 
      callable $function = '',
      int $position = null 

Example to Add Sub-menu in Custom Post Type
Write the following code in your functions.php file to Custom post type.

    • Login to your WordPress Admin Dashboard.
    • Now from the left sidebar go to Appearance -> Theme Editor.
    • Go to functions.php file and write the code below.

//admin menu callback function

function coupon_register_submenu_page() {

    //Add Offer Configuration Sub Menu   
    add_submenu_page('edit.php?post_type=coupon', 'coupon configuration', 'Coupon Configuration', "manage_options", 'coupon_configuration', 'couponconfiguration', '');

    //Add Deal Configuration Sub Menu
    add_submenu_page('edit.php?post_type=coupon', 'deal configuration', 'Deal Configuration', "manage_options", 'deal_configuration', 'dealconfiguration', '');

    //Add Custom Social Sharing Sub Menu
    add_submenu_page('edit.php?post_type=coupon', 'deal configuration', 'Social Options', "manage_options", 'social-share', 'social_share_page', '');
add_action('admin_menu', 'coupon_register_submenu_page');

//add submenu page callback function

function couponconfiguration(){
    echo 'Offer Configuration';

function dealconfiguration(){
    echo 'DEAL Configuration';

function social_share_page(){
    echo 'Social Sharing Configuration';

To get the right menu item to add the submenu, you need to check the URL that it takes you. For example, by clicking on the “Deal Configuration” button, it loads the page: localhost:8080/coupon/wp-admin/edit.php?post_type=coupon. So, the item that we will use will be ‘edit.php?post_type=coupon’.

coupon configuration in wordpress

In the WordPress admin panel you have a Custom Post Type called “Coupon”, and that’s where we added a submenu like- Coupon Configuration, Deal Configuration & Social Options.

To Continue Learning, you can refer our blog post Add Meta Box in Custom Post Type

Looking for a leading IT outsourcing company? Erudite Works Pvt Ltd: Trusted consultancy firm offering cutting-edge tech solutions for businesses. Partner to create innovative industry solutions. Contact Us.

Share this article...


Submit a Comment

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.