超贴心,WordPress 技巧:给后台特色图片加上大小说明

使用 WordPress 开发的时候,很多项目都会用到缩略图的功能,但是 WordPress 后台的特色图片上传得时候并没有提示图片的大小,这样给客户操作的时候带来了一定的问题,其实我们可以通过以下代码在特色图片上传的地方增加大小说明。

add_filter('admin_post_thumbnail_html', 'wpjam_admin_post_thumbnail_html',10,2);
function wpjam_admin_post_thumbnail_html($content, $post_id){
	$post = get_post($post_id);
	$post_type = $post->post_type;
	if($post_type == 'post'){
		return $content.'<p>大小:390x200</p>';
	}
	return $content;
}

最终效果:

 

感谢原作者:http://blog.wpjam.com/m/post-thumnail-with-size/

小 虾

哦也,我是小虾

You may also like...