When it comes to defining custom option pages, theme pages, menu pages, and submenu pages, the provided API makes this trivially easy; however, one of the less used aspects of these functions is the ability to define a custom WordPress menu hook.
For example, in a recent project I needed to do exactly that when adding a submenu to the WordPress Tools menu so I thought I’d share my process for doing exactly this.
Note that if you’re looking to add a submenu to a different WordPress menu, then there are a couple of options that are available. First and foremost, the most common option is to use add_submenu_page
and then use tools.php
as the parent slug as specified in the Codex.
But if you happen to be working with the Tools menu, then the add_management_page
function is your best bet because it’s designed for exactly that.
So for this article, that’s what I’ll be using.