Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattradford
Created November 10, 2021 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattradford/317fce4452ec1d3b9bf2c6e9a55be47a to your computer and use it in GitHub Desktop.
Save mattradford/317fce4452ec1d3b9bf2c6e9a55be47a to your computer and use it in GitHub Desktop.
Promote WordPress Categories to a top-level menu item
add_action('admin_menu', [$this, 'promoteCategories']);
/**
* Promote Categories to a top-level menu item
*
* @return void
*/
public function promoteCategories()
{
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category');
add_menu_page('Categories', 'Categories', 'manage_categories', 'edit-tags.php?taxonomy=category', '', 'dashicons-category');
}
@dmpinder
Copy link

Nice snippet!

Worth mentioning for anyone wanting to use this, the code assumes you're inside a Class. If you're not, then 2 small changes:

add_action('admin_menu', [$this, 'promoteCategories']);

changes to

add_action('admin_menu', 'promoteCategories');

and then

public function promoteCategories()

changes to

function promoteCategories()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment