Skip to content

Instantly share code, notes, and snippets.

@remscli
Created June 9, 2015 08:38
Show Gist options
  • Select an option

  • Save remscli/94e3e40512c3125861bc to your computer and use it in GitHub Desktop.

Select an option

Save remscli/94e3e40512c3125861bc to your computer and use it in GitHub Desktop.
Add an ACF value to a CPT list column
/**
* Add a "Author" column to theses CPT
*/
function add_theseauthor_columns($columns) {
$columns['theseAuthor'] = 'Author';
return $columns;
}
add_filter('manage_theses_posts_columns' , 'add_theseauthor_columns');
/**
* Get the ACF fields and display them in "theseAuthor" column
*/
function custom_columns( $column, $post_id ) {
if ( $column == 'theseAuthor') {
echo get_field('lastname', $post_id) . " " . get_field('firstname', $post_id);
}
}
add_action( 'manage_posts_custom_column' , 'custom_columns', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment