0

We can add some file in theme folder but it showing in the admin panel. We can't getting the theme folder file from

add_menu_page('Test', 'test', 'manage_options', 'test', 'test.php', null, 6); 
0

Fifth parameter of add_menu_page is of type callable. So you can't just give it "test.php" and expect it to load. But you could probably do something like:

// Include the fine with some function for example bananaMonday() declared
include_once( __DIR__ . '/test.php' );

// And then use it as param for add_menu_page
add_menu_page('Test', 'test', 'manage_options', 'test', 'bananaMonday', null, 6);

So in the end your full code would be something like this.

functions.php

function se331925_custom_menu_page() {
    // Include the fine with some function for example bananaMonday() declared
    include_once( __DIR__ . '/test.php' );

    // And then use it as param for add_menu_page
    add_menu_page('Test', 'test', 'manage_options', 'test', 'bananaMonday', null, 6);
}

add_action( 'admin_menu', 'se331925_custom_menu_page' );

test.php

function bananaMonday() {
    echo '<h1>Hello, it\'s monday';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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