Adding custom fields columns to CPT list
-
Hi,
I wanted to have extra columns on my custom posts list after creating a new post type (“Trips” in my case) in CPTUI and have these columns pull data from custom fields created by ACF. I have used this code:add_filter( 'manage_edit-trips_columns', 'my_edit_trips_columns' ) ; function my_edit_trips_columns( $columns ) { $columns = array( 'cb' => '<input type="checkbox" />', 'title' => __( 'Trip name' ), 'region' => __( 'Region' ), 'start_date' => __( 'Start date' ), 'date' => __( 'Date' ) ); return $columns; } add_action( 'manage_trips_posts_custom_column', 'my_manage_trips_columns', 10, 2 ); function my_manage_trips_columns( $column, $post_id ) { global $post; switch( $column ) { case 'region' : echo get_post_meta( $post_id , 'region' , true ); break; case 'start_date' : echo get_post_meta( $post_id , 'start_date' , true ); break; } }
This showed my columns and respective values beautifly. I also wanted also a column with the custom taxonomies to show. I created my custom taxonomies and selected the “Show Admin Column” setting to True. However the taxonomy column didn’t show up, alhtough it did when I disabled the above code. Is there a way to have the custom columns display AND the custom taxonomy column as well?
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Adding custom fields columns to CPT list’ is closed to new replies.