美文网首页
wordpress列表页缩略图

wordpress列表页缩略图

作者: 一叶一华年 | 来源:发表于2019-05-16 09:43 被阅读0次

实现效果


image.png

实现方法
外观--编辑--function.php添加代码

if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) {
 // for post and page
 add_theme_support('post-thumbnails', array( 'post', 'page' ) );
 function fb_AddThumbColumn($cols) {
 $cols['thumbnail'] = __('Thumbnail');
 return $cols;
 }
 function fb_AddThumbValue($column_name, $post_id) {
 $width = (int) 35;
 $height = (int) 35;
 if ( 'thumbnail' == $column_name ) {
 // thumbnail of WP 2.9
 $thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
 // image from gallery
 $attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') );
 if ($thumbnail_id)
 $thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
 elseif ($attachments) {
 foreach ( $attachments as $attachment_id => $attachment ) {
 $thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
 }
 }
 if ( isset($thumb) && $thumb ) {
 echo $thumb;
 } else {
 echo __('None');
 }
 }
 }
 // for posts
 add_filter( 'manage_posts_columns', 'fb_AddThumbColumn' );
 add_action( 'manage_posts_custom_column', 'fb_AddThumbValue', 10, 2 );
 // for pages
 add_filter( 'manage_pages_columns', 'fb_AddThumbColumn' );
 add_action( 'manage_pages_custom_column', 'fb_AddThumbValue', 10, 2 );
 }

详情见http://www.wazhuti.com/2487.html

相关文章

  • wordpress列表页缩略图

    实现效果 实现方法外观--编辑--function.php添加代码 详情见http://www.wazhuti.c...

  • wordpress列表页简述

    为了实现这个功能,找了很多,也试了很多,但一无所获。首先要找到这块简述所在的位置,才能够准确的进行修改。我是在外观...

  • 如何用php生成视频缩略图

    一些涉及到视频的业务,列表页显示视频列表需要视频的缩略图,一些云服务如七牛云等,可以再上传视频的同时自动生成缩略图...

  • iOS开发 多线程的使用场景

    1. 生成本地视频的缩略图 类似聊天页的小视频和本地视频列表这样的tableView在显示视频的缩略图时,需要使用...

  • iOS 缩略图

    iOS App 大都有列表页,需要在列表项中显示图片。图片基本上是从服务端获取,如果服务端没有返回缩略图,对于小图...

  • 移动设备上的列表中如何使用图片缩略图

    摘要:在决定是否要在列表项目中展示图片缩略图以及在哪放置缩略图时,要考虑缩略图与与缩略图相关联的文本俩者重要性大小...

  • 了解wordpress后台与业务逻辑的之间的关联

    1. 获取分类列表各自的内容 需要wordpress API WordPress函数:wp_list_catego...

  • wordpress添加缩略图

    在wordpress当中添加缩略图功能非常简单。 配置 首先我们需要在主题根目录当中找到functions.php...

  • 聊天缩略图背后的故事

    看似简单,无人注意过的缩略图也隐藏着有趣的细节 这里我们主要讨论聊天列表中展示的缩略图,缩略图通常是将图片内容进行...

  • vue keep-alive 实现详情返回列表保留页面数据

    实现功能 详情页返回列表页,列表页保留上次浏览位置 其它页面进入到列表表,列表页刷新 当详情页有数据改变时,列表页...

网友评论

      本文标题:wordpress列表页缩略图

      本文链接:https://www.haomeiwen.com/subject/zbrbaqtx.html