【发布时间】:2020-07-28 16:59:21
【问题描述】:
我已将此代码放在 wordpress 上的 index.php 中,但它没有显示任何内容。我认为它应该显示所有最新到最新的帖子。任何人都可以解决这个问题?
<div class="card">
<div class="card-image">
<a href="<?php echo the_permalink(); ?>">
<img src="<?php echo get_the_post_thumbnail_url(get_the_ID); ?>" alt="Card Image">
</a>
</div>
<div class="card-description">
<a href="<?php the_permalink(); ?>">
<h3><?php the_title(); ?></h3>
</a>
<div class="card-meta">
Đăng bởi <?php the_author(); ?> vào <?php the_time('j F, Y') ?> trong <a href="#"><?php echo get_the_category_list(',') ?></a>
</div>
<p>
<?php echo wp_trim_words(get_the_excerpt(), 30); ?>
</p>
<a href="<?php the_permalink(); ?>" class="btn-readmore">Tìm hiểu thêm</a>
</div>
</div>
<?php }
wp_reset_query();
?>
非常感谢。
【问题讨论】:
-
您在代码中使用
while (have_posts()) {the_post();?>吗?您的问题标题中有它,但代码本身没有。另外,您确定index.php是显示您正在尝试的任何页面的模板吗?许多主题都有专门用于页面、帖子、档案等的模板。