Wordpress:在Post View中显示自定义类型帖子的列表

时间:2014-10-07 20:42:46

标签: wordpress changelog

在单个帖子页面上,我需要能够显示来自特定自定义帖子类型的五个最新帖子的列表。它应该像更改日志一样工作。它们需要以这种格式显示:

(published date) (post content)
(published date) (post content)
(published date) (post content)
(published date) (post content)
(published date) (post content)

一般情况下,我知道要查找什么以及如何通过编辑主题来实现,但我想知道是否有任何插件或插件组合可以帮助我比编辑主题文件更容易实现这一点?我并不懒于这样做,但我需要在许多需要快速构建的新wordpress网站上进行,我没有时间手动编辑每个wordpress主题。

这是一个实际的例子:网站上有一篇关于某个在线软件的帖子很受欢迎并且获得了流量。必须在帖子中显示更改日志,需要定期更新。因此,网站的管理员只需在一个句子中输入新的更改日志,单击发布,它将在帖子中显示有关软件的信息,从而创建一个包含更改日志的列表。

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用以下代码

<?php $args = array( 'post_type' => 'your post name here','posts_per_page' => 5 );
 $myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<?php echo get_the_time('Y-m-d', $post->ID);
echo the_content();
?><?php endforeach;