Created
June 9, 2015 08:38
-
-
Save remscli/94e3e40512c3125861bc to your computer and use it in GitHub Desktop.
Add an ACF value to a CPT list column
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 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