-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsingle.php
45 lines (43 loc) · 1.3 KB
/
single.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
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="row">
<div class="col-md-8 col-md-offset-1">
<center>
<?php
if (has_post_thumbnail()) {
// 显示特色图像
the_post_thumbnail();
} else {
// 设置特色图像
$attachments = get_posts(array(
'post_type' => 'attachment',
'post_mime_type'=>'image',
'posts_per_page' => 0,
'post_parent' => $post->ID,
'order'=>'ASC'
));
if ($attachments) {
foreach ($attachments as $attachment) {
set_post_thumbnail($post->ID, $attachment->ID);
break;
}
// 显示特色图像
the_post_thumbnail();
}
} ?>
<a href="<?php the_permalink(); ?>"><h1><?php the_title(); ?></h1></a>
——· <?php the_time('Y年n月j日') ?> | <?php comments_popup_link('0 条评论', '1 条评论', '% 条评论', '', '评论已关闭'); ?> ·——
</center>
<hr>
<psize><?php the_content(); ?></psize>
<hr>
<?php comments_template(); ?>
</div>
<div class="col-md-2">
<?php get_sidebar(); ?>
</div>
</div>
<?php endwhile; else: ?>
<p><?php _e('(⊙o⊙)…没有文章喔……'); ?></p>
<?php endif; ?>
<?php get_footer(); ?>