62

The problem with @tollmanz answer is that since you're hooking off of the -print-styles and -print-scripts hooks, you must generate the HTML to load your scripts manually. This is not optimal, since you don't get the nice dependency and versioning that comes with wp_enqueue_script() and wp_enqueue_style(). It also doesn't let you put things in the footer if ...


61

You need to use the right hooks (which are not always the same as the URLs/slugs), and it doesn't hurt to use a hook that runs later (e.g., admin_init): add_action( 'admin_init', 'wpse_136058_remove_menu_pages' ); function wpse_136058_remove_menu_pages() { remove_menu_page( 'edit.php?post_type=acf' ); remove_menu_page( 'wpcf7' ); } You can use ...


59

Yes. When you register your post type you need to set show_in_menu to the page you would like it displayed on. Adding a custom post type as a sub-menu of Posts Here we set the "movies" post type to be included in the sub-menu under Posts. register_post_type( 'movies', array( 'labels' => array( 'name' => __( '...


33

add_menu_page and add_submenu_page both return the page's "hook suffix", which can be used to identify the page with certain hooks. As such, you can use that suffix in combination with the variable hooks admin_print_styles-{$hook_suffix} and admin_print_scripts-{$hook_suffix} to specifically target these pages. function my_menu() { $menu = add_menu_page( ...


27

Otto has suggested a fix in Chrome itself until the bug is resolved: Go to chrome://flags/#disable-slimming-paint Enable the "Disable slimming paint" option. Ensure that the "Enable slimming paint" option below it is not turned on. Relaunch Chrome. If you don't want to take this approach you can fix this with CSS: function chromefix_inline_css() { ...


23

From the docs on add_submenu_page(), you see that you can hide your submenu link from a top level menu item to which it belongs be setting the slug (1st argument) to null: add_action( 'admin_menu', 'register_my_custom_submenu_page' ); function register_my_custom_submenu_page() { add_submenu_page( null, 'My Custom Submenu Page', ...


17

You need just two steps: Hook into the action admin_menu, register the page with a callback function to print the content. In your callback function load the file from plugin_dir_path( __FILE__ ) . "included.html". Demo code: add_action( 'admin_menu', 'wpse_91693_register' ); function wpse_91693_register() { add_menu_page( 'Include Text', ...


17

// PLUGINS THAT ADD AS DASHBOARD SUBMENU // IF THIS IS THE URL BELOW - THE PAGE VARIABLE IS WHAT I NEED ( SO WHATEVER COMES AFTER PAGE= ) // http://example.com/wp-admin/index.php?page=iconize-plugin-update-notifier remove_submenu_page( 'index.php', 'iconize-plugin-update-notifier' ); // OR FOR EXAMPLE WOOCOMMERCE DASHBOARD SUBMENU ...


15

The correct hook to use is admin_menu and then create a function to remove the menus you want to remove. The following 2 functions remove all the menus. add_action( 'admin_menu', 'remove_admin_menus' ); add_action( 'admin_menu', 'remove_admin_submenus' ); //Remove top level admin menus function remove_admin_menus() { remove_menu_page( 'edit-comments....


15

You probably need to set the add_action priority to a higher number and target those two new links specifically like so: add_action( 'admin_menu', 'my_remove_menu_pages', 999 ); function my_remove_menu_pages() { remove_menu_page( 'edit.php' ); //Posts remove_menu_page( 'upload.php' ); //Media remove_menu_page( 'edit-...


13

Positions for Core Menu Items 2 Dashboard 4 Separator 5 Posts 10 Media 15 Links 20 Pages 25 Comments 59 Separator 60 Appearance 65 Plugins 70 Users 75 Tools 80 Settings 99 Separator Parameter description for "menu position" $position (integer) (optional) The position in the menu order this menu should appear. By default, if this parameter is omitted, ...


13

If you use get_current_screen(), you can detect what the page you're on is. There is an example in the codex article that I linked which shows how to use get_current_screen() with add_options_page(), this method will work for any admin page.


13

add_action('admin_menu', 'my_remove_sub_menus'); function my_remove_sub_menus() { remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category'); remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag'); }


12

I made this work iterating through a post types list, and pinpointing the correct $menu key for the post type using a secondary function (instead of manually iterating through the $menu object). Function reference: get_post_types and wp_count_posts. add_action( 'admin_menu', 'pending_posts_bubble_wpse_89028', 999 ); function ...


12

You have some messed up code. I have reformatted your code to code which actually works. The following solution allows you to give your Custom Post Type menu a menu name of what ever you want. Just change the label "menu_name". POST TYPE // Create the news custom post type register_post_type('nwcm_news', array( 'labels' => array( '...


11

Doing this search, I've found this fine answer by Chris_O. There's even a jQuery solution I proposed there. Anyway, the function remove_menu_page('edit.php'); only removes the Posts menu. But, as we learn from Chris answer, remove_menu_page('edit.php?post_type=athletes'); removes the Custom Post Type menu. To really block access to the URL, as we're ...


11

customize should work. I was able to remove the Customize link with the following code: add_action( 'wp_before_admin_bar_render', 'wpse200296_before_admin_bar_render' ); function wpse200296_before_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu('customize'); }


10

Yes, this capability is available with register_post_type, via the show_in_menu argument, but whether or not the particular plugin you are using supports this I don't know. add_action( 'init', 'wpa70679_custom_types' ); function wpa70679_custom_types() { register_post_type( 'parent_type', array( 'public' => true, '...


10

I am less convinced that I know what you are doing than I once was. // Add menu and pages to WordPress admin area add_action('admin_menu', 'myplugin_create_top_level_menu'); function myplugin_create_top_level_menu() { // This is the menu on the side add_menu_page( 'MyPlugin', 'MyPlugin', 'manage_options', 'myplugin-top-...


10

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 right after 'nav-menu' JS wp_add_inline_script( 'nav-menu', 'wpNavMenu.options.globalMaxDepth = 1;', 'after' ); } add_action( 'admin_enqueue_scripts', '...


9

Here's an example of the data returned from the wp_get_update_data() function: Array ( [counts] => Array ( [plugins] => 3 [themes] => 2 [wordpress] => 0 [translations] => 0 [total] => 5 ) [title] => 3 Plugin Updates, 2 Theme Updates ) So the number of ...


9

I did same error first time I implemented WP_List_Table. The problem is that when you call WP_List_Table::display() WordPress in turn calls: WP_List_Table::display_rows_or_placeholder() WP_List_Table::display_rows() WP_List_Table::single_row() WP_List_Table::single_row_columns() Last function is called for every row. If you look at its code (see source), ...


8

Here's how I recently added a custom taxonomy to the media library as a sortable column: // Add a new column add_filter('manage_media_columns', 'add_topic_column'); function add_topic_column($posts_columns) { $posts_columns['att_topic'] = _x('Topic', 'column name'); return $posts_columns; } // Register the column as sortable function ...


8

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 labels (WP 4.7.1). You do not have to change everything. add_filter( 'post_type_labels_post', 'news_rename_labels' ); /** * Rename default post type to news * * @...


8

I've not worked with the admin-bar before. However, I found your question interesting and decided to take a look. If you add a function to handle the action hook 'admin_bar_menu' and set the priority to be higher than 70, you will have access to the raw admin_bar_menu nodes where you can modify the properties you are trying to access. Below is a detailed set ...


8

You need to add your hook at the end of the queue and then remove menu by slug: function remove_menu_links() { if( !current_user_can( 'manage_options' ) ) { remove_menu_page( 'gf_edit_forms' ); // this is the pages url } } add_action( 'admin_menu', 'remove_menu_links', 9999 ); If you want to remove submenu you need to use following snippet: ...


8

Use a submenu page as parent slug. The admin menu has just two levels, so the imaginary third level will be hidden. Sample code, tested: add_action( 'admin_menu', 'wpse_73622_register_hidden_page' ); function wpse_73622_register_hidden_page() { add_submenu_page( 'options-writing.php', 'Hidden!', 'Hidden!', 'exists', ...


8

function remove_submenu() { remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&post_type=question' ); remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-tags&post_type=question' ); } add_action( 'admin_menu', 'remove_submenu', 999 ); Please read the Codex. remove_submenu_page() need two parameters and the right ...


8

Update I created a code snippet with a more robust function that deals with both main menus and sub-menu items. Original answer Instead of specifying the menus you want to remove, specify the menues you want to keep :) add_action('admin_init', 'nwcm_admin_init'); function nwcm_admin_init() { // Remove unnecessary menus $menus_to_stay = array(...


8

Add this to your theme's functions.php: add_action( 'admin_bar_menu', 'make_parent_node', 999 ); function make_parent_node( $wp_admin_bar ) { if ( ! is_admin() ) { return; } // end function if not in admin back-end, credit @Rarst $args = array( 'id' => 'view-site', // id of the existing child node (View Site) 'title' => '...


Only top voted, non community-wiki answers of a minimum length are eligible