function populate_admin_columns( $column, $post_id ) {

        // Get wordpress $post object.
        global $post;

        // determine the column
        switch( $column ) {

            // If column is a taxonomy associated with the post type.
            case ( taxonomy_exists( $column ) ) :

                // Get the taxonomy for the post
                $terms = get_the_terms( $post_id, $column );

                // If we have terms.
                if ( ! empty( $terms ) ) {

                    $output = array();

                    // Loop through each term, linking to the 'edit posts' page for the specific term.
                    foreach( $terms as $term ) {

                        // Output is an array of terms associated with the post.
                        $output[] = sprintf(

                            // Define link.
                            '<a href="%s">%s</a>',

                            // Create filter url.
                            esc_url( add_query_arg( array( 'post_type' => $post->post_type, $column => $term->slug ), 'edit.php' ) ),

                            // Create friendly term name.
                            esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, $column, 'display' ) )
                        );

                    }

                    // Join the terms, separating them with a comma.
                    echo join( ', ', $output );

                // If no terms found.
                } else {

                    // Get the taxonomy object for labels
                    $taxonomy_object = get_taxonomy( $column );

                    // Echo no terms.
                    printf( __( 'No %s', $this->textdomain ), $taxonomy_object->labels->name );
                }

            break;

            // If column is for the post ID.
            case 'post_id' :

                echo $post->ID;

            break;

            // if the column is prepended with 'meta_', this will automagically retrieve the meta values and display them.
            case ( preg_match( '/^meta_/', $column ) ? true : false ) :

                // meta_book_author (meta key = book_author)
                $x = substr( $column, 5 );

                $meta = get_post_meta( $post->ID, $x );

                echo join( ", ", $meta );

            break;

            // If the column is post thumbnail.
            case 'icon' :

                // Create the edit link.
                $link = esc_url( add_query_arg( array( 'post' => $post->ID, 'action' => 'edit' ), 'post.php' ) );

                // If it post has a featured image.
                if ( has_post_thumbnail() ) {

                    // Display post featured image with edit link.
                    echo '<a href="' . $link . '">';
                        the_post_thumbnail( array(60, 60) );
                    echo '</a>';

                } else {

                    // Display default media image with link.
                    echo '<a href="' . $link . '"><img src="'. site_url( '/wp-includes/images/crystal/default.png' ) .'" alt="' . $post->post_title . '" /></a>';

                }

            break;

            // Default case checks if the column has a user function, this is most commonly used for custom fields.
            default :

                // If there are user custom columns to populate.
                if ( isset( $this->custom_populate_columns ) && is_array( $this->custom_populate_columns ) ) {

                    // If this column has a user submitted function to run.
                    if ( isset( $this->custom_populate_columns[ $column ] ) && is_callable( $this->custom_populate_columns[ $column ] ) ) {

                        // Run the function.
                        call_user_func_array(  $this->custom_populate_columns[ $column ], array( $column, $post ) );

                    }
                }

            break;
        } // end switch( $column )
    }
function populate_admin_columns( $column, $post_id ) {

        // Get wordpress $post object.
        global $post;

        // determine the column
        switch( $column ) {

            // If column is a taxonomy associated with the post type.
            case ( taxonomy_exists( $column ) ) :

                // Get the taxonomy for the post
                $terms = get_the_terms( $post_id, $column );

                // If we have terms.
                if ( ! empty( $terms ) ) {

                    $output = array();

                    // Loop through each term, linking to the 'edit posts' page for the specific term.
                    foreach( $terms as $term ) {

                        // Output is an array of terms associated with the post.
                        $output[] = sprintf(

                            // Define link.
                            '<a href="%s">%s</a>',

                            // Create filter url.
                            esc_url( add_query_arg( array( 'post_type' => $post->post_type, $column => $term->slug ), 'edit.php' ) ),

                            // Create friendly term name.
                            esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, $column, 'display' ) )
                        );

                    }

                    // Join the terms, separating them with a comma.
                    echo join( ', ', $output );

                // If no terms found.
                } else {

                    // Get the taxonomy object for labels
                    $taxonomy_object = get_taxonomy( $column );

                    // Echo no terms.
                    printf( __( 'No %s', $this->textdomain ), $taxonomy_object->labels->name );
                }

            break;

            // If column is for the post ID.
            case 'post_id' :

                echo $post->ID;

            break;

            // if the column is prepended with 'meta_', this will automagically retrieve the meta values and display them.
            case ( preg_match( '/^meta_/', $column ) ? true : false ) :

                // meta_book_author (meta key = book_author)
                $x = substr( $column, 5 );

                $meta = get_post_meta( $post->ID, $x );

                echo join( ", ", $meta );

            break;

            // If the column is post thumbnail.
            case 'icon' :

                // Create the edit link.
                $link = esc_url( add_query_arg( array( 'post' => $post->ID, 'action' => 'edit' ), 'post.php' ) );

                // If it post has a featured image.
                if ( has_post_thumbnail() ) {

                    // Display post featured image with edit link.
                    echo '<a href="' . $link . '">';
                        the_post_thumbnail( array(60, 60) );
                    echo '</a>';

                } else {

                    // Display default media image with link.
                    echo '<a href="' . $link . '"><img src="'. site_url( '/wp-includes/images/crystal/default.png' ) .'" alt="' . $post->post_title . '" /></a>';

                }

            break;

            // Default case checks if the column has a user function, this is most commonly used for custom fields.
            default :

                // If there are user custom columns to populate.
                if ( isset( $this->custom_populate_columns ) && is_array( $this->custom_populate_columns ) ) {

                    // If this column has a user submitted function to run.
                    if ( isset( $this->custom_populate_columns[ $column ] ) && is_callable( $this->custom_populate_columns[ $column ] ) ) {

                        // Run the function.
                        call_user_func_array(  $this->custom_populate_columns[ $column ], array( $column, $post ) );

                    }
                }

            break;
        } // end switch( $column )
    }
function populate_admin_columns ( $ column , $ post_id ) { // Get wordpress $post object. global $ post ; // determine the column switch ( $ column ) { // If column is a taxonomy associated with the post type. case ( taxonomy_exists ( $ column ) ) : // Get the taxonomy for the post $ terms = get_the_terms ( $ post_id , $ column ) ; // If we have terms. if ( ! empty ( $ terms ) ) { $ output = array ( ) ; // Loop through each term, linking to the 'edit posts' page for the specific term. foreach ( $ terms as $ term ) { // Output is an array of terms associated with the post. $ output [ ] = sprintf ( // Define link. '<a href="%s">%s</a>' , // Create filter url. esc_url ( add_query_arg ( array ( 'post_type' => $ post -> post_type , $ column => $ term -> slug ) , 'edit.php' ) ) , // Create friendly term name. esc_html ( sanitize_term_field ( 'name' , $ term -> name , $ term -> term_id , $ column , 'display' ) ) ) ; } // Join the terms, separating them with a comma. echo join ( ', ' , $ output ) ; // If no terms found. } else { // Get the taxonomy object for labels $ taxonomy_object = get_taxonomy ( $ column ) ; // Echo no terms. printf ( __ ( 'No %s' , $ this -> textdomain ) , $ taxonomy_object -> labels -> name ) ; } break ; // If column is for the post ID. case 'post_id' : echo $ post -> ID ; break ; // if the column is prepended with 'meta_', this will automagically retrieve the meta values and display them. case ( preg_match ( '/^meta_/' , $ column ) ? true : false ) : // meta_book_author (meta key = book_author) $ x = substr ( $ column , 5 ) ; $ meta = get_post_meta ( $ post -> ID , $ x ) ; echo join ( ", " , $ meta ) ; break ; // If the column is post thumbnail. case 'icon' : // Create the edit link. $ link = esc_url ( add_query_arg ( array ( 'post' => $ post -> ID , 'action' => 'edit' ) , 'post.php' ) ) ; // If it post has a featured image. if ( has_post_thumbnail ( ) ) { // Display post featured image with edit link. echo '<a href="' . $ link . '">' ; the_post_thumbnail ( array ( 60 , 60 ) ) ; echo '</a>' ; } else { // Display default media image with link. echo '<a href="' . $ link . '"><img src="' . site_url ( '/wp-includes/images/crystal/default.png' ) . '" alt="' . $ post -> post_title . '" /></a>' ; } break ; // Default case checks if the column has a user function, this is most commonly used for custom fields. default : // If there are user custom columns to populate. if ( isset ( $ this -> custom_populate_columns ) && is_array ( $ this -> custom_populate_columns ) ) { // If this column has a user submitted function to run. if ( isset ( $ this -> custom_populate_columns [ $ column ] ) && is_callable ( $ this -> custom_populate_columns [ $ column ] ) ) { // Run the function. call_user_func_array ( $ this -> custom_populate_columns [ $ column ] , array ( $ column , $ post ) ) ; } } break ; } // end switch( $column ) }
Populate admin columns

Populate custom columns on the admin edit screen.

@param string $column The name of the column.
@param integer $post_id The post ID.
Populate admin columns