-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathcontent-thumb.php
49 lines (48 loc) · 1.91 KB
/
content-thumb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Template part for displaying posts.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package Mokore
*/
$i=0; while ( have_posts() ) : the_post(); $i++;
$class = ($i%2 == 0) ? 'post-list-thumb-left' : ''; // 如果为偶数
if(has_post_thumbnail()){
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
$post_img = $large_image_url[0];
}else{
$post_img = get_bloginfo('template_url') . 'http://wx2.sinaimg.cn/small/006rG8asly1fzte2eg8hvj30jg0chaao.jpg';
}
$the_cat = get_the_category();
?>
<article class="post post-list-thumb <?php echo $class; ?>" itemscope="" itemtype="http://schema.org/BlogPosting">
<div class="post-thumb">
<a href="<?php the_permalink(); ?>" style="background-image: url(<?php echo $post_img; ?>);"></a>
</div><!-- thumbnail-->
<div class="post-content-wrap">
<div class="post-content">
<div class="post-date">
<i class="iconfont"></i><?php echo poi_time_since(strtotime($post->post_date_gmt)); ?>
<?php if(is_sticky()) : ?>
<i class="iconfont hotpost"></i>
<?php endif ?>
</div>
<a href="<?php the_permalink(); ?>" class="post-title"><h3><?php the_title();?></h3></a>
<div class="post-meta">
<span><i class="iconfont"></i><?php echo get_post_views(get_the_ID()); ?> 热度</span>
<span class="comments-number"><i class="iconfont"></i><?php comments_popup_link('NOTHING', '1 条评论', '% 条评论'); ?></span>
<span><i class="iconfont"></i><a href="<?php echo esc_url(get_category_link($the_cat[0]->cat_ID)); ?>"><?php echo $the_cat[0]->cat_name; ?></a>
</span>
</div>
<div class="float-content">
<?php the_excerpt(); ?>
<div class="post-bottom">
<a href="<?php the_permalink(); ?>" class="button-normal"><i class="iconfont"></i></a>
</div>
</div>
</div>
</div>
</article>
<?php
endwhile;