Skip to content

Instantly share code, notes, and snippets.

@dcooney
Created September 20, 2014 16:07
Show Gist options
  • Save dcooney/7f95ab73f6c5c5c4605b to your computer and use it in GitHub Desktop.
Save dcooney/7f95ab73f6c5c5c4605b to your computer and use it in GitHub Desktop.
Custom post type columns with custom fields
// Add custom columns to milsstones post type
function my_milestone_columns($columns){
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'year' => 'Year',
'month' => 'Month',
'date' => 'Date',
);
return $columns;
}
function my_custom_milestone_columns($column, $post_id){
switch ( $column ) {
case 'year' :
echo get_field('year');
break;
case 'month' :
echo get_field('month');
break;
}
}
add_filter( 'manage_edit-milestone_columns', 'my_milestone_columns' );
add_action( 'manage_milestone_posts_custom_column' , 'my_custom_milestone_columns', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment