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

Move excerpt meta box to above content editor

It’s simple, just unregister postexcerpt box first then add another one on the top. Here is my code add_action( ‘admin_menu’, function () { remove_meta_box(‘postexcerpt’, ‘post’, ‘normal’); }, 999 ); add_action(‘edit_form_after_title’, ‘post_excerpt_meta_box’);

Add screen options to custom admin pages

You don’t need to invent a new screen option row. Just use proper metaboxes. Currently, you are drawing pseudo-metaboxes: <!– Post status start–> <div class = “postbox”> <div class = “handlediv”> <br> </div> <h3 class = “hndle”><span><?php _e(“By Post Status”, ‘bulk-delete’); ?></span></h3> <div class = “inside”> <h4><?php _e(“Select the posts which you want to delete”, … Read more

How do I remove dashboard access from specific user roles?

To lock subscribers and contributors out of the admin: function wpse23007_redirect(){ if( is_admin() && !defined(‘DOING_AJAX’) && ( current_user_can(‘subscriber’) || current_user_can(‘contributor’) ) ){ wp_redirect(home_url()); exit; } } add_action(‘init’,’wpse23007_redirect’); Hope that helps. All roles give the user a capability that is the name of that role, so you can use any role name as a capability.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)