How to create Custom Menu in wordpress admin panel
// Create a file under the theme folder Yourname.php
/* How to add menu into the admin */
add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
add_menu_page('Show Recodes', // page name
'View Resume', // menu name
'manage_options', // not change
'Second-menu', // Page is display to admin panel it is display in url
'my_menu_output', // function name
'dashicons-welcome-view-site', // icon url or icon name
3
/*
where to display
Default: bottom of menu structure #Default: bottom of menu structure
2 – Dashboard
4 – Separator
5 – Posts
10 – Media
15 – Links
20 – Pages
25 – Comments
59 – Separator
60 – Appearance
65 – Plugins
70 – Users
75 – Tools
80 – Settings
99 – Separator
Top ↑
For the Network Admin menu, the values are different: #For the Network Admin menu, the values are different:
2 – Dashboard
4 – Separator
5 – Sites
10 – Users
15 – Themes
20 – Plugins
25 – Settings
30 – Updates
99 – Separator
*/
);
}
function my_menu_output() {
global $wpdb;
$results = $wpdb->get_results("SELECT * FROM wp_users"); // Query to fetch data from database table and storing in $results
if($results != null)
print_r($results);
if(!empty($results)) // Checking if $results have some values or not
{
echo "
"; // Adding
echo "";
foreach($results as $row){
$userip = $row->user_ip; //putting the user_ip field value in variable to use it later in update query
echo " "; // Adding rows of table inside foreach loop
echo "
ID
" . "" . $row->ID . "
";
echo "
";
echo " ";
echo "
User Login
" . "" . $row->user_login . "
"; //fetching data from user_ip field
echo "
"; echo "
";
echo " ";
echo "
User Email Address
" . "" . $row->user_email . "
";
echo "
"; echo "
";
echo " ";
echo "
Register Time
" . "" . $row->user_registered . "
";
echo "
"; echo "
";
}
echo "
"; echo "
";
}
}
?>
// goto the functions.php add line bottom of the page
require_once('Yourname.php');
// reffer more information
// to icon
https://developer.wordpress.org/resource/dashicons/#share-alt2
// to add_menu_page()
https://developer.wordpress.org/reference/functions/add_menu_page/
// to get result
https://developer.wordpress.org/reference/classes/wpdb/get_results/
Comments
Post a Comment