Sort CPT archive by order prevents sorting in admin

I forgot to add !is_admin() check to my pre_get_posts function. Altered section of code below. add_action( ‘pre_get_posts’, ‘mpe_portfolio_sort_order’); function mpe_portfolio_sort_order($query){ if(is_archive() && ! is_admin() ): $query->set( ‘order’, ‘ASC’ ); $query->set( ‘orderby’, ‘menu_order’ ); endif; };

Add column to plugins table screen

First, you have to add the custom column to the plugin column names: function wpa65189_add_plugins_column( $columns ) { $columns[‘wpa65189_column’] = ‘wpa65189 Custom Column’; return $columns; } add_filter( ‘manage_plugins_columns’, ‘wpa65189_add_plugins_column’ ); Then output your column data for your plugin: function wpa65189_render_plugins_column( $column_name, $plugin_file, $plugin_data ) { if ( ‘wpa65189_column’ == $column_name && ‘My Plugin Name’ == … Read more

Sorting custom admin column by value

Ah, the remedy was a simple one: function issue_column_orderby( $vars ) { if ( isset( $vars[‘orderby’] ) && ‘linked_issue_post’ == $vars[‘orderby’] ) { $vars = array_merge( $vars, array( ‘meta_key’ => ‘article_issue_n’, ‘orderby’ => ‘meta_value’ ) ); } return $vars; } add_filter( ‘request’, ‘issue_column_orderby’ ); I probably omitted something before…

Sorting taxonomy columns by meta value numeric

The code I am posting is a modified and simplified version of yours. I got my solution using your code. /** * Filter WP_Term_Query meta query * * @param object $query WP_Term_Query * @return object */ function filter_terms_clauses( $pieces, $taxonomies, $args ) { global $pagenow, $wpdb; if(!is_admin()) { return $pieces; } if( is_admin() && $pagenow … Read more

how to display “Edit | Quick Edit | Trash | View” in custom WP_List_Table column?

Those links are hard-coded to display in the “title” column as part of class-wp-posts-list-table.php. Look at the single_row() method in that file, specifically the case ‘title’ to see how those links are constructed. You can probably re-use the same code in your plugin or theme as long as you comply with the GPL license WordPress … Read more

How to remove Gravatar from Username column

Since there is no special avatar column to unset (the avatars are inside the username column), you could try instead to hide the avatars via css: function hide_avatars_wpse_94126() { if(!current_user_can(‘manage_options’)){ // hide only for non-admins echo “<style>.users td.username img.avatar{display:none !important;}</style>”; } } add_action(‘admin_head-users.php’,’hide_avatars_wpse_94126′); where they are hidden for non-admins. The result will be like this:

Add column for attachment file size

Working code: // Add custom column with file size info to attachment page add_filter( ‘manage_media_columns’, ‘bb2_manage_media_columns’, 10, 2 ); function bb2_manage_media_columns( $columns ) { $columns[‘filesize’] = __( ‘Storlek’, ‘bb2’ ); return $columns; } add_action( ‘manage_media_custom_column’, ‘bb2_manage_media_custom_column’, 10, 2 ); function bb2_manage_media_custom_column( $column_name, $id ) { switch ( $column_name ) { case ‘filesize’ : $bytes = … Read more

How to set default visible columns in posts list, for all users

Since the question was about columns and not meta boxes and I needed this solution, Ioannis’ reply got me on the right track. The filter hook in question is default_hidden_columns. This is the solution I ended up with to set my ad_shortcode column to be hidden by default. You should know that this is just … Read more