How to add custom columns to Custom Post Type admin screen

The code from ThinkVitamin is right. I think the problem came from else where in your code. Actually, the hook manage_edit-${post_type}_columns takes an argument $columns which is an array of all registered columns. To add a new column, just add a new element to this array, like this: add_filter(‘manage_edit-film_columns’, ‘my_columns’); function my_columns($columns) { $columns[‘views’] = … Read more

initial sort order for a sortable custom column in admin

Instead of adding your column label “view” as a string, pass it in as an array with 1 as the second value. Like this: array(‘view’,1) Full Code: add_filter( ‘manage_edit-post_sortable_columns’, ‘my_sortable_view_column’ ); function my_sortable_view_column( $columns ) { $columns[‘post_views’] = array(‘view’,1); return $columns; } I don’t have a WP Codex for this, but I found someone else … Read more

Add new column to sites page

here is a modified version of your class that should work: class Add_Blog_ID { public static function init() { $class = __CLASS__ ; if ( empty( $GLOBALS[ $class ] ) ) $GLOBALS[ $class ] = new $class; } public function __construct() { add_filter( ‘wpmu_blogs_columns’, array( $this, ‘get_id’ ) ); add_action( ‘manage_sites_custom_column’, array( $this, ‘add_columns’ ), … Read more

Modify column_author in WP_Comments_List_Table

This is how the email part is displayed by the WP_Comments_List::column_author() method: /* This filter is documented in wp-includes/comment-template.php */ $email = apply_filters( ‘comment_email’, $comment->comment_author_email, $comment ); if ( ! empty( $email ) && ‘@’ !== $email ) { printf( ‘<a href=”https://wordpress.stackexchange.com/questions/258903/%1$s”>%2$s</a><br />’, esc_url( ‘mailto:’ . $email ), esc_html( $email ) ); } so you’re … Read more

Add “Last Edited by” column to custom post type list table

Changing admin columns belongs to a plugin, not to a theme file, because themes should never change anything else than frontend output. You can get the complete plugin here: Plugin Product Editor Column. Looking at the docs you linked to, I see the plugin author requires a child class that mixes multiple separate tasks. That’s … Read more

sortable custom column in media library

You cannot do a sort on the attachment meta data specifically because it’s stored in a serialized string. Whilst WP_Query can sort on meta values it can’t sort on data that’s serialized. For example wp_get_attachment_metadata fetches and unserializes that for you inside the column callback, but MySQL queries can’t sort on that type of data. … Read more

Custom sortable columns ordered by meta-value?

It’s because you are checking ‘event_date’ == $vars[‘event_date’] not ‘event_date’ == $vars[‘orderby]. But don’t use the request filter. Instead: add_action( ‘pre_get_posts’, ‘event_column_orderby’ ); function event_column_orderby( $query ) { if( ! is_admin() ) return; $orderby = $query->get( ‘orderby’); if( ‘event_date’ == $orderby ) { $query->set(‘meta_key’,’_wr_event_date’); $query->set(‘orderby’,’meta_value_num’); } } … and don’t manually set the order as … Read more