How can I add columns to the post edit listing to show my custom post data?

You add the column using the manage_posts_column filter, where you add two new array elements with a custom key name and the header name as the value. add_filter(‘manage_posts_columns’, ‘wpse_3531_add_seo_columns’, 10, 2); function wpse_3531_add_seo_columns($posts_columns, $post_type) { $posts_columns[‘seo_score’] = ‘SEO score’; $posts_columns[‘seo_keyword’] = ‘SEO keyword’; return $posts_columns; } The function that displays each row, _post_row(), then fires … Read more

Change default admin page for specific role(s)

In your theme’s functions.php: function hide_the_dashboard() { global $current_user; // is there a user ? if ( is_array( $current_user->roles ) ) { // substitute your role(s): if ( in_array( ‘custom_role’, $current_user->roles ) ) { // hide the dashboard: remove_menu_page( ‘index.php’ ); } } } add_action( ‘admin_menu’, ‘hide_the_dashboard’ ); function your_login_redirect( $redirect_to, $request, $user ) { … Read more

Load js/css files only on specific admin UI pages

The right hooks // Use both for scripts & styles *) wp_enqueue_scripts // (for the frontend) login_enqueue_scripts // (for the login screen) admin_enqueue_scripts // (for the admin dashboard) *) Read this article @wpdevel. Further reading in the Codex about the three hooks admin_menu network_admin_menu user_admin_menu On the admin_enqueue_scripts hook, you have an argument as well: … Read more

Prevent trash/delete action on specific post types

Here’s another approach using the map_meta_cap filter that’s applied within the map_meta_cap() function within the has_cap() method of the WP_User class (PHP 5.4+): add_filter( ‘map_meta_cap’, function ( $caps, $cap, $user_id, $args ) { // Nothing to do if( ‘delete_post’ !== $cap || empty( $args[0] ) ) return $caps; // Target the payment and transaction post … Read more

File not found.