WordPress dashboard Custom Admin Menus

Add in Menu in WordPress Dashboard they simple snippet here. Add below snippet in your plugin file or theme functions.php file to display Menu as “Event” and sub menu as “Event Setting”.

in you can set call PHP file as like “include_once”.

Syntax :


add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );

add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function );

Example :


add_action('admin_menu', 'register_event_menu');

function register_event_menu() {
    add_menu_page('Event', 'Event', 'manage_options', 'event_details', 'event_function', 'dashicons-clipboard');
    add_submenu_page('event_details', 'Event Setting', 'Event Setting', 'manage_options', 'event_setting', 'event_settings_function');
}

function event_function() {
	
   include_once('display_event.php');	
}



function event_settings_function() {
	echo "<div class='warp'>";
    echo "<h2>Admin Page DalwadiWp</h2>";
	echo "</div>";
	
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s