Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Njengah/0764f2c88742c19b67a212c914c9f25f to your computer and use it in GitHub Desktop.

Select an option

Save Njengah/0764f2c88742c19b67a212c914c9f25f to your computer and use it in GitHub Desktop.

Revisions

  1. Njengah created this gist Jan 22, 2020.
    28 changes: 28 additions & 0 deletions add-submenu-page_to_custom_post_type_example.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    <?php

    // Hook

    add_action('admin_menu', 'add_tutorial_cpt_submenu_example');

    //Callback function

    function add_tutorial_cpt_submenu_example(){

    add_submenu_page(
    'edit.php?post_type=tutorial', //$parent_slug
    'Tutorial Subpage Example', //$page_title
    'Tutorial Settings', //$menu_title
    'manage_options', //$capability
    'tutorial_subpage_example',//$menu_slug
    'tutorial_subpage_example_render_page'//$function
    );
    }

    //callback function

    function tutorial_subpage_example_render_page() {

    echo '<h2> Tutorial Subpage Example </h2>';

    }