Created
October 26, 2019 00:51
-
-
Save leepettijohn/e419d061b7bd35f79ab71f37d055ac7c to your computer and use it in GitHub Desktop.
Admin View of Post Type - Add ACF field to 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
<?php | |
/* *** add fields from ACF to columns in admin view **** | |
https://pluginrepublic.com/add-acf-fields-to-admin-columns/ | |
CHANGE | |
- manage_model_posts_columns (replace "model" with post type slug) | |
- manage_model_posts_custom_column (replace "model" with post type slug) | |
- model_order (replace with ACF slug) | |
*/ | |
function add_acf_columns ( $columns ) { | |
return array_merge ( $columns, array ( | |
'model_order' => __ ( 'Order' ), | |
) ); | |
} | |
add_filter ( 'manage_model_posts_columns', 'add_acf_columns' ); | |
function model_custom_column ( $column, $post_id ) { | |
switch ( $column ) { | |
case 'model_order': | |
echo get_post_meta ( $post_id, 'model_order', true ); | |
break; | |
} | |
} | |
add_action ( 'manage_model_posts_custom_column', 'model_custom_column', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment