alphabetically order role drop-down selection in dashboard

Almost the same approach One Trick Pony has chosen, but I am using translated names and uasort() (to preserve the keys): add_filter( ‘editable_roles’, ‘t5_sort_editable_roles’ ); /** * Array of roles. * * @wp-hook editable_roles * @param array $roles * @return array */ function t5_sort_editable_roles( $roles ) { uasort( $roles, ‘t5_uasort_editable_roles’ ); return $roles; } /** … Read more

Adding Custom Post Type Counts to the Dashboard

Yes, there are several actions within that widget, including right_now_content_table_end. Example: function my_right_now() { $num_widgets = wp_count_posts( ‘widget’ ); $num = number_format_i18n( $num_widgets->publish ); $text = _n( ‘Widget’, ‘Widgets’, $num_widgets->publish ); if ( current_user_can( ‘edit_pages’ ) ) { $num = “<a href=”https://wordpress.stackexchange.com/questions/5318/edit.php?post_type=widget”>$num</a>”; $text = “<a href=”https://wordpress.stackexchange.com/questions/5318/edit.php?post_type=widget”>$text</a>”; } echo ‘<tr>’; echo ‘<td class=”first b b_pages”>’ . … Read more

Hide dashboard from non-admin users

As far as ease of use, especially for WordPress Admins not too firm in PHP, I second brasoflo’s plugin recommendation (Adminimize). For the sake of completeness, this is how it’d be done programmatically: /* Remove the “Dashboard” from the admin menu for non-admin users */ function wpse52752_remove_dashboard () { global $current_user, $menu, $submenu; get_currentuserinfo(); if( … Read more

Remove dashboard, use Pages tab as default

The best way is to re-direct user logins to your page and also remove the dashboard from the menu, this can be done with 2 filters. Redirect logins to your page edit screen example based on user roles, this example uses “author”: function dashboard_redirect($url) { global $current_user; // is there a user ? if(is_array($current_user->roles)) { … Read more

Show Custom Taxonomy Inside Custom Menu

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( … Read more

Displaying Custom Post Types In “At A Glance” Meta Box

Here is the function that I use to display CPT in the “At a glance” widget add_action( ‘dashboard_glance_items’, ‘cpad_at_glance_content_table_end’ ); function cpad_at_glance_content_table_end() { $args = array( ‘public’ => true, ‘_builtin’ => false ); $output=”object”; $operator=”and”; $post_types = get_post_types( $args, $output, $operator ); foreach ( $post_types as $post_type ) { $num_posts = wp_count_posts( $post_type->name ); $num … Read more

WordPress dashboard, viewing CPT results in 504

The CPT and taxonomy terms are created via plugin. I was able to lessen the query by adding the following to my plugin: add_action( ‘pre_get_posts’, ‘nwtd_lpfs_custom_admin_query’ ); function nwtd_lpfs_custom_admin_query( $query ) { if( !is_admin() && !$query->is_main_query() ) { return; } if( is_post_type_archive( ‘services’ ) ) { $query->set(‘no_found_rows’, 1 ); $query->set(‘update_post_meta_cache’, 0 ); $query->set(‘update_post_term_cache’, 0 ); … Read more

Why not register shortcodes if is_admin dashboard?

I have observed the same issue with contact-form-7 a while back. But note that registering shortcodes based on is_admin is doing_it_wrong (see gmazzap`s answer) There are the two reasons that seem legitimate at first sight (and why they are wrong): (Unlikely) The plugin author tried to optimize the script to only register shortcodes when they … Read more