Created
December 7, 2020 08:52
-
-
Save elliottmangham/f6c73cbe5c4cee4eb196229aac8b6bd1 to your computer and use it in GitHub Desktop.
WordPress / Add fields to admin columns
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
function fnCustomAwardEditTableCol( $aColumns ) { | |
$aColumns = [ | |
'cb' => '<input type="checkbox" />', | |
'title' => 'Title', | |
'certificate' => 'Certificate', | |
'award_body' => 'Awarding Body' | |
]; | |
return $aColumns; | |
} | |
function fnCustomAwardTableCol( $column ) { | |
global $post; | |
// Certificate | |
if ( $column == 'certificate' ) { | |
echo get_field( 'certificate', $post->ID ); | |
// Award categories | |
} elseif ( $column == 'award_body' ) { | |
echo strip_tags( get_the_term_list( $post->ID, 'award_body', "", ", ", "" ) ); | |
} | |
} | |
add_action( 'manage_award_posts_custom_column', 'fnCustomAwardTableCol' ); | |
add_filter( 'manage_edit-award_columns', 'fnCustomAwardEditTableCol' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment