In writing my plugin, I have added my menus and submenus to the admin page. The pages load and function as intended. What I am trying to do is create some links inside of these pages that will pass a parameter to a new page. I am close to accomplishing this but the page always opens up outside of the admin screen. I am quite new at this and completely stuck.

Here is a screenshot.

How can I get a link from an admin page to open inside of the admin panel?

Here is the function I am calling to get the post data which will pass the id to the page that handles the database edit.

add_action( 'admin_post_add_recid', 'prefix_admin_add_recid' );
function prefix_admin_add_recid() {        
    include( plugin_dir_path( __FILE__ ) . '/management_tools/edit.php' );

and the link that calls it, where 1 is the id that i need to pass to the edit page.


Here is background on what/why I am doing this if you want to be bored. I am migrating content from a non-wordpress site. The only thing wordpress can't accommodate right out of the box is some old php database stuff that has been around for awhile. I want to put this database code into a plugin so that it can be managed within wordpress, backed up and migrated if that need ever arises. It is a specific use plugin that is not going to be distributed. The existing code hasn't been modified since it was created and probably won't need modified again once it is in wordpress. All of the database read and insert code is working inside of the plugin. Basically I am really close to completing the task without having to rewrite it from scratch which I don't have the budget to do. I just can't find a way to open the edit/delete admin pages inside of the admin panel. Thanks for reading and for any help you can offer.


2 Answers 2


Call the same page with a parameter and include the content depending on the parameter:

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.

define(PLUG_NAME, "my_admin");

//hook to add an item in the menu admin 
add_action('admin_menu', 'my_admin_setup_menu');

function my_admin_setup_menu(){
        //1st : title of the page, 2nd : title in the menu menu
        add_menu_page( 'My plugin page', 'My plugin', 'manage_options', 'my_admin', 'my_plugin_init' );

function my_plugin_init(){

    //links inside the page
    $page_link1="<a href=\"admin.php?page=".PLUG_NAME."&idp=1\">link 1</a>";
    $page_link2="<a href=\"admin.php?page=".PLUG_NAME."&idp=2\">link 2</a>";
    $page_link3="<a href=\"admin.php?page=".PLUG_NAME."&idp=3\">link 3</a>";

    //get the id of the page we want to display 
    // then we include the page
    if (isset($_GET['idp'])){

        $page =(int) $_GET['idp'];

        switch ($page) {
            case 1:
            case 2:
            case 3:
        include( plugin_dir_path( __FILE__ ) . $page_inc);


        echo "<h1>My plugin home</h1>";
        //display the link in the main page
        echo $page_link1."<br/>";
        echo $page_link2."<br/>";
        echo $page_link3."<br/>";       


I'm not sure I've understood the question entirely, but there is the wp_redirect function that can redirect the user to a different URL.

$url = admin_url("admin-post.php?action=add_recid&data=1");

if (wp_redirect($url)) {
    exit ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.