Tag Info

Hot answers tagged

33

Here's the process to change the labels (I changed posts to "contacts" in my example) function change_post_menu_label() { global $menu; global $submenu; $menu[5][0] = 'Contacts'; $submenu['edit.php'][5][0] = 'Contacts'; $submenu['edit.php'][10][0] = 'Add Contacts'; $submenu['edit.php'][15][0] = 'Status'; // Change name for categories ...


20

Here's a quick and dirty way to get what you want. Background WordPress stores admin menu sections in a global array called $menu. To add a separator you add an element to the $menu array using an index that is between the indexes of the options that you want to separate. Using the add_admin_menu_separator() function So I've written a function to ...


18

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 ...


14

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( ...


13

Here is a list of all of the above answers and a removal of the admin bar link. Just add it to your themes function file or make it a plugin. I will mark this as a community wiki as everyone's answer is right just no one added it all together. <?php // Removes from admin menu add_action( 'admin_menu', 'my_remove_admin_menus' ); function ...


10

Codex - Register Post Type See the capability_type and capabilities arguments for register_post_type. You can pass the capabilities argument an array of capabilities to map to the necessary caps, here's an example of the args array with custom capabilities. $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => ...


10

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.


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

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 ...


7

this might work: add_filter('custom_menu_order', 'my_custom_menu_order'); add_filter('menu_order', 'my_custom_menu_order'); function my_custom_menu_order($menu_ord) { if (!$menu_ord) return true; return array( 'index.php', // the dashboard link 'edit.php?post_type=custom_post_type', 'edit.php?post_type=page', ...


7

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 ...


7

On the function to register a new custom post type can you set this CPT as Submenu to a exist menu item. Use the param show_in_menu A example: register_post_type( 'issue', apply_filters( 'wpit_register_issue_post_type', array( 'labels' => $issue_labels, 'rewrite' => $issue_rewrite, ...


7

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' => __( ...


6

Wordpress SEO If you want to remove the admin menu: you can do that with: function hide_wpseo() { remove_action('admin_menu', 'zeo_options_menu'); } add_action( 'init', 'hide_wpseo'); where it will be removed for all users. WordPress SEO by Yoast To hide the admin menu: and the admin menu bar: one can use: function hide_yoastseo() { ...


6

Add an admin menu separator Separators, if this question targets this, are the dividers of the admin menu that separate the menu into sections. Per default it's divided into a "publish" and an "administration" area. Plugin for the rescue Here's what we're going to have afterwards: A custom separator. I wrote a pretty simple plugin that I run as ...


6

Remember Apple's "Goto Fail"? Similar situation: Your code actually does this, when indentation is corrected: foreach ( $post_types as $post_type ) remove_meta_box('trackbacksdiv', $post_type, 'normal'); remove_meta_box('postcustom', $post_type, 'normal'); remove_meta_box('authordiv', $post_type, 'normal'); remove_meta_box('postexcerpt', ...


6

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 ...


6

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, ...


6

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.


6

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 ...


6

If you wrote your code correctly, then delete_option would be the correct way. The question isn't how to clear the option; the question is how to structure your code such that the "option does not exist" case is a valid case. Think about it. The first time you start this code, that option isn't going to exist at all, right? Your code should be perfectly ...


6

Not really, no. You can override built-in PHP functions, but not user-defined functions. However, all this function does is define a meta box. Why not define your own? Once you've got your own meta box defined and added, you can call remove_meta_box to remove the standard one: remove_meta_box( 'add-POSTTYPENAME', 'nav-menus', 'side'); The meta box is ...


6

Update: reading mike's answer again got me thinking that you can add a new capability to a role and use that as you removal condition, so: // first add your role the capability like so // get the "author" role object $role = get_role( 'administrator' ); // add "see_all_menus" to this role object $role->add_cap( 'see_all_menus' ); ...


6

you can create a function that redirects to the front-end like this: function redirect_home_987(){ wp_redirect( home_url() ); exit; } and call that function in WordPress default add_menu_page function like this: add_menu_page( 'redirecting', 'View Site', 'read', 'my-top-level-handle', 'redirect_home_987'); Hope this helps


5

Something like this should work. $handle should be the menu's slug; set $sub to true to search submenus (defaults to top level menus): function find_my_menu_item( $handle, $sub = false; ){ if( !is_admin() || (defined('DOING_AJAX') && DOING_AJAX) ) return false; global $menu, $submenu; $check_menu = $sub ? $submenu : $menu; if( empty( ...


5

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', ...


5

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 ...


5

Your menu slug (5th parameter) can't be the same across multiple pages, and it obviously can't have an & in it, but you can have all the pages you want call the same callback function (the last param). add_submenu_page('upload_manage', "Programs", "Programs", 'manage_options', 'manage-programs', "manage_data"); add_submenu_page('upload_manage', ...


5

To remove the Comments menu: add_action( 'admin_init', 'my_remove_admin_menus' ); function my_remove_admin_menus() { remove_menu_page( 'edit-comments.php' ); }


5

here is the simplest implementation I know of since there is no real API: //add the needed scripts and styles add_action('admin_enqueue_scripts', 'wpse_46028_enqueue_admin_scripts'); function wpse_46028_enqueue_admin_scripts() { wp_enqueue_style('wp-pointer'); wp_enqueue_script('wp-pointer'); //hook the pointer ...



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