Displaying page content from plugin, inside exising empty WP page

Old php developer here, very.. very new to WP, so be kind.

I am building my first WP Plugin. I have this in the plugin central file (the one that is /plugins/my_plugin/my_plugin.php):

// Setup the admin management page
function wx_admin_burger_management() {
    add_menu_page(
        'Burger Manager',           // Page title
        'Burger Manager',           // Menu title
        'manage_options',           // Capability
        'admin-manage-burger',      // Menu slug
        'wx_burger_admin',          // Callback function
        'dashicons-list-view',      // Menu icon
        '3'                         // Priority
    );
}

function wx_burger_admin() {
    include(trailingslashit(WX_PLUGIN_PATH).'my-burger-admin.php');
}
add_action('admin_menu', 'wx_admin_burger_management');

This works exactly as it is supposed to, which is encouraging. It adds a page to the Admin menu that lets admin type people do admin type things.

I have used WP to create a blank page with a suitable menu item, that shows once the regular user on the front end is logged in. It does not show to an un-logged-in user. The menu item points to sitename.com/my-burger/ which has the wonderful title of My Burger at the top. Nothing else is displayed on this page currently. I am trying to get content to be pulled from another php document inside my plugins directory, to show up here. Currently I am attempting (and failing) to do this using:

function wx_burger_user_page_content() {
include(trailingslashit(WX_PLUGIN_PATH).'burger-management-user.php');
}
add_action('my-burger', 'wx_burger_user_page_content');

There is no menu section to callback from, since the menu is already in place from the WP side of things.

I am presuming that the problem is my add_action line, specifically the 'my-burger' part. I'm guessing I need to change this for a hook of some type that is aware the page is called and then triggers the wx_burger_user_page_content() function to display burger-management-user.php within the page.

Am I correct, and if so, how do I go about discovering the hook that I should be using here to achieve this?

TIA

Topic include actions pages plugins Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.