Here we learn about how to add a custom column in custom post type list in the admin side WordPress.
Custom code copied and paste into your child theme’s functions.php file.
<?php function myblog_display_rank_column_data( $column, $post_id ) { global $wpdb; switch ( $column ) { case 'rank' : $rank = get_post_meta( $post_id, 'optimus_rank_field', true ); if( $rank != '9999' && $rank != '' ) { echo $rank; } else { echo '-'; } break; } } // add_action( 'manage_{custom_post_type}_custom_column' , 'myblog_display_rank_column_data', 10, 2 ); orignal hook add_action( 'manage_posts_custom_column' , 'myblog_display_rank_column_data', 10, 2 ); function myblog_add_rank_column( $columns ) { $columns['rank'] = __( 'Rank', 'enfold' ); return $columns; } //add_filter( 'manage_{custom_post_type}_columns' , 'myblog_add_rank_column' ); orignal hook add_filter( 'manage_posts_columns' , 'myblog_add_rank_column' ,20); ?>
OUTPUT: