Skip to content

Instantly share code, notes, and snippets.

@dcangulo
Last active April 3, 2018 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcangulo/3395d983bc8f4cd63e31eeb33c02a61d to your computer and use it in GitHub Desktop.
Save dcangulo/3395d983bc8f4cd63e31eeb33c02a61d to your computer and use it in GitHub Desktop.
A WordPress plugin template with menu and submenu. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: My WordPress Plugin
Plugin URI: https://wordpress.org/plugins/
Description: Just another WordPress plugin.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
*/
add_action('admin_menu', 'addMenuHooks');
function addMenuHooks(){
add_menu_page( 'Appointments', 'Appointments', 'manage_options', 'appointments', 'mainMenu','dashicons-calendar-alt');
add_submenu_page( 'appointments', 'Pending', 'Pending', 'manage_options', 'appointments-pending', 'subMenu' );
}
function mainMenu() {
echo "<h2>My WordPress Plugin</h2>Hello world! I'm the main menu.";
}
function subMenu() {
echo "<h2>My WordPress Plugin</h2>Hello world! I'm the submenu.";
}
//Visit the tutorial for more information
//https://www.davidangulo.xyz/website-development/how-to-add-submenu-in-wordpress-custom-plugin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment