Created
November 10, 2021 14:42
-
-
Save mattradford/317fce4452ec1d3b9bf2c6e9a55be47a to your computer and use it in GitHub Desktop.
Promote WordPress Categories to a top-level menu item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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()