Sortable admin columns, when data isn’t coming from post_meta
See the follow-up post: http://scribu.net/wordpress/sortable-taxonomy-columns.html
See the follow-up post: http://scribu.net/wordpress/sortable-taxonomy-columns.html
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
Why not just hide the column from view using CSS ? .column-yourcolumnname { display: none; }
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
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
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
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
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
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
Your problem is a simple typo: array($this, ‘manage_post_columns’, 10, 2) VS. array($this, ‘manage_post_columns’), 10, 2 I guess you see the difference