首页 > 新闻资讯 > 添加缩略图

添加缩略图

4条评论
标签:
更多

添加这段代码到functions.php之后,管理栏将增加一个文章缩略图功能,添加这个功能之后,就可以很清楚的看到有哪些文章已经添加了缩略图。这段代码首先会检查你的主题是否支持缩略图功能,避免发生错误。

if (function_exists( 'add_theme_support' )){
    add_filter('manage_posts_columns', 'posts_columns', 5);
    add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
    add_filter('manage_pages_columns', 'posts_columns', 5);
    add_action('manage_pages_custom_column', 'posts_custom_columns', 5, 2);
}
function posts_columns($defaults){
    $defaults['wps_post_thumbs'] = __('Thumbs');
    return $defaults;
}
function posts_custom_columns($column_name, $id){
    if($column_name === 'wps_post_thumbs'){
        echo the_post_thumbnail( array(125,80) );
    }
}

* 版权声明:作者WordPress啦! 转载请注明出处。

#1
挺实用的
#2
相当相当的不错。我算是测试过的了。
#3
不错不错的分享哈!
#4
值得借鉴

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.