manage posts screen admin column 添加缩略图和post format

Published
2023-01-09
浏览次数 :  9

//在文章管理栏添加post format 

function manage_posts_add_format_column( $columns ) {
	$columns['format'] = __('格式');
        return $columns;
}
add_filter( 'manage_posts_columns' , 'manage_posts_add_format_column' );


function posts_custom_format_columns( $column_name, $id ) {
    if ( 'format' === $column_name ) {
    echo get_post_format($id);
    }
}
add_action( 'manage_posts_custom_column', 'posts_custom_format_columns', 5, 2 );

function wpdocs_posts_thumb_columns( $columns ) {
    $post_new_columns = array(
       'post_thumbs' => esc_html__( 'Thumbs', 'text_domain' ),
    );
    return array_merge( $columns, $post_new_columns );
}
add_filter( 'manage_posts_columns', 'wpdocs_posts_thumb_columns', 5 );

function wpdocs_posts_custom_columns( $column_name, $id ) {
    if ( 'post_thumbs' === $column_name ) {
        the_post_thumbnail( 'thumbnail' );
    }
}
add_action( 'manage_posts_custom_column', 'wpdocs_posts_custom_columns', 5, 2 );

  • 标签1
  • 标签1
  • 标签1
Top