I think the manage_{$post_type}_posts_columns
filter is what you’re looking for. You can then use the manage_posts_custom_column
action to manage the content for each column in the posts list view.
EDIT::
To add custom columns to your custom post type, you need to filter the columns being output using the manage_{$post_type}_posts_columns
where $post_type
is the name you used to register the custom post type. In your case it would be spark_stars
.
The $columns
variable is an array of the current columns. You can either add to it completely override it as necessary.
add_filter('manage_spark_stars_posts_columns','filter_cpt_columns');
function filter_cpt_columns( $columns ) {
// this will add the column to the end of the array
$columns['first_name'] = 'First Name';
//add more columns as needed
// as with all filters, we need to return the passed content/variable
return $columns;
}
The next step is to tell WordPress what content needs to be displayed in the column.
This can be done with the manage_posts_custom_column
action. The method below outputs the First Name
if the post meta exists or a default string if not.
add_action( 'manage_posts_custom_column','action_custom_columns_content', 10, 2 );
function action_custom_columns_content ( $column_id, $post_id ) {
//run a switch statement for all of the custom columns created
switch( $column_id ) {
case 'first_name':
echo ($value = get_post_meta($post_id, 'first_name_meta_box_key', true ) ) ? $value : 'No First Name Given';
break;
//add more items here as needed, just make sure to use the column_id in the filter for each new item.
}
}
Hopefully this is more clear!