15
votes
Changing Admin Menu Labels
To rename default post type (or any other for that matter) just use filter post_type_labels_{$post_type}. For default post it will be post_type_labels_post. In the code below is the full list of ...
15
votes
remove_menu_page doesn't work on custom plugin menus
Place this below temporary code in your functions.php or any where that can be executed.
add_action( 'admin_init', 'the_dramatist_debug_admin_menu' );
function the_dramatist_debug_admin_menu() {
...
13
votes
How to limit wordpress menu depth in admin panel
The solution that I came up with:
/**
* Limit max menu depth in admin panel to 2
*/
function q242068_limit_depth( $hook ) {
if ( $hook != 'nav-menus.php' ) return;
// override default value ...
12
votes
Remove Categories / Tags From Admin Menu
If you want to completely remove categories and tags you can do so like this:
// Remove Categories and Tags
add_action('init', 'myprefix_remove_tax');
function myprefix_remove_tax() {
...
12
votes
Accepted
How to add custom submenu links in wp-admin menus?
For the custom link into the admin menu, you need to pick up a top-level menu item by its slug and register the function using the admin_menu action hook.
Here is the list of Main Admin Menu slugs.
...
12
votes
Accepted
Custom WP_List_Table displays blank rows
You're getting the blank rows because your column headers are registered late. And you should register the headers (i.e. initialize the list table class instance) before admin notices are rendered on ...
11
votes
Accepted
How to remove items from +New admin menu?
To hide everything (menu and submenu)-
function wpse_260669_remove_new_content(){
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'new-content' );
}
add_action( '...
11
votes
Accepted
Hide Theme options and Customize Admin menu
Direct answer:
add_action( 'admin_menu', function() {
global $current_user;
$current_user = wp_get_current_user();
$user_name = $current_user->user_login;
//check condition ...
9
votes
Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu
Our custom post type:
$args['show_in_menu'] = false;
register_post_type('custom_plugin_post_type', $args);
Add him for existing Custom Post Type ("product" for example):
$existing_CPT_menu = 'edit....
9
votes
Accepted
remove_menu_page doesn't work on custom plugin menus
Thanks to the answer that the_dramatist posted, it was a matter of just hooking to the admin_init tag. The slugs for those plugin pages can be retrieved by the debug script that the_dramatist provided,...
8
votes
Accepted
How to add notification bubble for my custom admin menu page
OK, so it has nothing to do with WP_List_Table, to be precise. All you need to do is to add some additional info during registration of your custom admin page.
There are two classes used by WordPress ...
8
votes
How to fix the admin menu margin-top bug in WordPress 5.5?
I ran into that issue too, and it turns out that it was because there actually was an error that wasn't displaying. Once I fixed that underlying error, the top margin problem went away.
This is in wp-...
7
votes
Appearance->Editor not visible
I had a similar problem (albeit 3 years later) and after some research I had a process for potentially identifying the source of the problem and subsequently found that my issue was hidden in a plugin ...
7
votes
Why I can't change the permalink of this page?
Make sure to check the permalinks of YOUR IMAGES also (in "Media"->"Library") as they create a permalink ("post" type) if you upload an image with a filename that is ...
7
votes
Accepted
renaming an admin menu item with decimal array index number
You have to use a string as key:
$menu['26.0648'][0] = 'Event Calendar';
If you write the key as a number, it will truncate the decimal to an integer, so 26.0648 will be truncated to 26.
6
votes
How do I Enqueue styles/scripts on Certain /wp-admin Pages?
As @mor7ifer mentioned above, you can use the native WordPress function get_current_screen(). If you loop through the output of this function, e.g.:
$current_screen = get_current_screen();
foreach($...
6
votes
Accepted
How to change admin menu position of "Media"?
There's a combination of two filters, menu_order does the job, but you also use custom_menu_order to enable menu_order.
function wpse_233129_custom_menu_order() {
return array( 'index.php', '...
6
votes
Accepted
'Headers already sent' Error When Redirecting from add_submenu_page() Callback
Background
The infamous "Headers already sent" error rears it's ugly head in circumstances where something attempts to modify the HTTP headers for the server's response after they have ...
6
votes
Accepted
Reorder custom submenu item
Got it, thanks to cjbj's help, I was able to get the final solution:
add_filter( 'custom_menu_order', 'submenu_order' );
function submenu_order( $menu_order ) {
# Get submenu key location based ...
6
votes
add_menu_page() with function inside a class
add_action must be inside the plugin class and should look like
add_action( 'admin_menu', array( $this, 'add_menu_items' ) );
Usually this line presents in the __construct() method.
6
votes
Hide Theme options and Customize Admin menu
This would work in WordPress 5
add_action( 'admin_menu', function() {
remove_submenu_page( 'themes.php', 'customize.php?return=' . urlencode($_SERVER['SCRIPT_NAME']));
});
6
votes
Accepted
wrapping 'rest_api_init' in 'is_admin()' function
Essentially, you shouldn't wrap your REST route declarations inside is_admin() since Wordpress will not load them (see @DarkNueron comment).
What you can do is pass a 'permission_callback' function to ...
5
votes
How do I Enqueue styles/scripts on Certain /wp-admin Pages?
To make it, you have to find the admin page name first. Add admin_enqueue_scripts with wp_die($hook) and go to your specific plugin page, You will see the page name.
function my_plugin_scripts($hook) ...
5
votes
Remove query var on admin pages when 'Save changes' pressed
This might be useful: there is a filter called removable_query_args. You get an array of argument names to which you can append your own argument. Then WP will take care of removing all of the ...
5
votes
Accepted
How to limit wordpress menu depth in admin panel
Follow up on @jmarceli's and @squarecandy's great answers. Here is a solution that allows for:
Easier scaling (set an object in the php action)
Updates to the correct menu depth when the location ...
5
votes
Accepted
How do I set up a webhook?
You are using self-hosted WordPress, which sometimes referred to as WordPress.org.
Calling remote hook is still a possibility there, but unless your e-commerce solution supports it, you may need to ...
5
votes
Accepted
Remove Pagination in Appearance -> Menus -> Categories
As per Stackoverflow Stackoverflow
Ok after reading through the source code I found that the number of categories returned in the edit menu section is hardcoded to 50 on line 613 of \wp-admin\...
5
votes
Accepted
How to add Font Awesome 5 icons in WP Admin dashboard menu?
Just like with Font Awesome 4, you can enqueue styles in your theme to take effect on the admin pages. This allows you get styles needed for Font Awesome icons to be used. Just update your functions ...
4
votes
Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?
Looking for a solution on the web but didn't found. Simply does this trick (for example). Here you have the native list of positions:
2 Dashboard
4 Separator
5 Posts
10 Media
15 Links
...
4
votes
Order Admin sub-menu items?
I know I'm necro-posting but I recently had the same issue. Please note that I used Rao's solution on SO to get to this answer.
Assuming your CPT is called "notes".
/**
* @see https://codex....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
admin-menu × 645wp-admin × 120
admin × 103
plugin-development × 82
custom-post-types × 80
plugins × 64
menus × 56
sub-menu × 39
add-menu-page × 34
functions × 31
customization × 30
php × 28
user-roles × 27
dashboard × 26
admin-bar × 25
add-submenu-page × 24
options × 22
custom-taxonomy × 18
theme-development × 18
pages × 18
multisite × 17
capabilities × 16
settings-api × 14
hooks × 13
custom-field × 12