Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Add custom column in custom post type (here custom_post = latest_at_sonic)
- add_filter( 'manage_edit-latest_at_sonic_columns', 'my_edit_latest_at_sonic_columns' ) ;
- function my_edit_latest_at_sonic_columns( $columns ) {
- $columns = array(
- 'cb' => '<input type="checkbox" />',
- 'title' => __( 'Title' ),
- 'description' => __( 'Description' ),
- 'thumbnail' => __( 'Thumbnail' ),
- 'date' => __( 'Date' )
- );
- return $columns;
- }
- add_action( 'manage_latest_at_sonic_posts_custom_column', 'my_manage_latest_at_sonic_columns', 10, 2 );
- function my_manage_latest_at_sonic_columns( $column, $post_id ) {
- global $post;
- switch( $column ) {
- /* If displaying the 'description' column. */
- case 'description' :
- /* Get the post meta. */
- $description = get_the_content( $post_id );
- $short_desc = substr($description, 0, 80);
- /* If no short_desc is found, output a default message. */
- if ( empty( $short_desc ) )
- echo __( '-' );
- /* If there is a short_desc, append 'minutes' to the text string. */
- else
- printf( __( '%s' ), $short_desc );
- break;
- /* If displaying the 'thumbnail' column. */
- case 'thumbnail' :
- /* Get the genres for the post. */
- $thumbnail = get_the_post_thumbnail( $post_id, array( 100, 100) );
- /* If terms were found. */
- if ( !empty( $thumbnail ) ) {
- /* Join the terms, separating them with a comma. */
- echo $thumbnail;
- }
- /* If no terms were found, output a default message. */
- else {
- _e( '-' );
- }
- break;
- /* Just break out of the switch statement for everything else. */
- default :
- break;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement