Skip to content

Instantly share code, notes, and snippets.

@elliottmangham
Created December 7, 2020 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliottmangham/f6c73cbe5c4cee4eb196229aac8b6bd1 to your computer and use it in GitHub Desktop.
Save elliottmangham/f6c73cbe5c4cee4eb196229aac8b6bd1 to your computer and use it in GitHub Desktop.
WordPress / Add fields to admin columns
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