Hello readers, If you are a WordPress developer, its essentials to know ” How to add a new menu to Dashboard” when you are try to make any custom theme or plugin. Now i am going to show the functions and wp hooks for adding Custom Dashboard Menu.
Q 1 : What is WordPress Hooks?
WordPress hooks are arguably the basis of WordPress development, forming a large part of the core functionality and used by almost every plugin and theme available to date. WordPress hooks are, essentially, triggers of sorts that allow users to, with short snippets of code, modify areas a WordPress theme or plugin, or add their own code to various parts of WordPress without modifying the original files. An example of this could be along the lines of either “when WordPress chooses which template file to load, run our custom code” or “when you generate the content for each post, add social bookmarking links to the end of the content”. These examples will be expanded upon once we’re a bit more familiar with what exactly the different types of hooks are.
I shall discuss more about hooks later.
Step 1 :
Define A Function
add_menu_page( page_title, menu_title, capability, menu_slug, function, icon_url, position );
/* add_menu_page(‘JS Login Activities’, ‘JS Login Act’, ‘manage_options’, ‘js-login-activities’, ‘general’, plugins_url(‘img/icon_16x16.png’, __FILE__),50); */
Step 2 :
Define A Function For Menu Page
include( plugin_dir_path( __FILE__ ) . ‘yourpage.php’);
/* include( plugin_dir_path( __FILE__ ) . ‘panel/general.php’); */
Step 3 :
Add A Hook