Custom Admin Page

I use these for those occasions when I need to store specialized information in non-WordPress tables. (Such as orders in a custom shopping cart I built.)

It’s also handy for adding informational or instructional pages to the Dashboard.

This adds the page to the WP admin menu (put in your functions.php file):

// admin page for orders
add_action( 'admin_menu', 'lt_orders' );

function lt_orders() {
    add_menu_page( 'Orders', 'Orders',  'manage_options',  'lt-orders',   'lt_render', '', '3'   );
}
function lt_render() {
    global $title;
    print '<div class="wrap">';
    print "<h2>$title</h2>";
    $file = plugin_dir_path( __FILE__ ) . "lt_orders.php";
    if ( file_exists( $file ) )
        require $file;
    print '</div>';
}

┬áThe page itself ( lt_orders.php ) resides in the theme folder, and is a simple PHP page, with any functionality you like. It doesn’t need any header or footer calls because it is rendered inside the admin.

Comments are closed.

Skip to toolbar