Created
September 20, 2014 16:07
-
-
Save dcooney/7f95ab73f6c5c5c4605b to your computer and use it in GitHub Desktop.
Custom post type columns with custom fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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