add_action('admin_menu', 'myplugin_create_top_level_menu');
function myplugin_create_top_level_menu() {
add_menu_page(
'MyPlugin',
'MyPlugin',
'manage_options',
'myplugin-top-level-page'
);
add_submenu_page(
'myplugin-top-level-page',
'MyPlugin Top Level Page',
'MyPlugin Top Level Page',
'manage_options',
'myplugin-top-level-page',
'myplugin_top_level_page_callback'
);
add_submenu_page(
null,
'MyPlugin Details Page',
'MyPlugin Details Page',
'manage_options',
'myplugin-details-page',
'myplugin_details_page_callback'
);
}
function myplugin_top_level_page_callback() {
global $wpdb;
$results_from_db = $wpdb->get_results("SELECT * FROM myplugin_custom_table");
foreach ($results_from_db as $result) {
$id = $result->id;
$link = add_query_arg(
array(
'page' => 'myplugin-details-page',
'id' => $id
),
admin_url('admin.php')
);
echo '<ul>';
echo '<li><a href="'.$link.'">'.$id.'</a><li>';
echo '</ul>';
}
}
function myplugin_details_page_callback () {
}