• Hey,

    Does anyone know of a plugin, or a way to add another column to the add / manage posts page in the wordpress admin area?

    I have a lot of plugins with extra blocks and I’d like a way to tidy them up a bit.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter threevisual

    (@threevisual)

    anyone have any ideas? thanks.

    Obviously some function names could do with changing be here you can remove unwanted columns, add new ones and populate the new ones. You can also style the new columns.

    add_action('admin_head', 'header');
    add_filter('manage_posts_columns', 'remove_unwanted_columns');
    add_filter('manage_posts_columns', 'posts_columns', 5);
    add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
    
    // Add CSS for new column
    function header(){
    ?>
    	<style type="text/css">
    		table.widefat th.column-riv_post_ids,{
    			width: 50px;
    		}
    	</style>
    <?php
    }
    
    // Remove any unwanted columns
    function remove_unwanted_columns($defaults){
        unset($defaults['comments']);
        return $defaults;
    }
    
    // Create a new column called 'ID'
    function posts_columns($defaults){
        $defaults['riv_post_ids'] = __('ID');
        return $defaults;
    }
    
    // Populate the new column with the Post ID
    function posts_custom_columns($column_name, $id){
    	if($column_name === 'riv_post_ids'){
            echo (int)$id;
        }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add column to post admin page?’ is closed to new replies.