Wordpress:在帖子视图中显示自定义类型帖子的列表
问题描述:
在单帖子页面上,我需要能够显示来自某个自定义帖子类型的五个最新帖子的列表。它应该像改变日志一样工作。他们需要显示格式为:Wordpress:在帖子视图中显示自定义类型帖子的列表
(published date) (post content)
(published date) (post content)
(published date) (post content)
(published date) (post content)
(published date) (post content)
总的来说,我知道要寻找什么,以及如何通过编辑主题做了,但我不知道是否有插件的任何插件或组合将帮我做到这一点比编辑主题文件更容易?我并不懒惰,但是我需要在许多新的WordPress网站上做这些,这些网站需要快速构建,而且我没有时间手动编辑每个WordPress主题。
下面是一个实际的例子:网站上有一篇关于某个在线软件的帖子,该软件很流行,可以获取流量。更新日志必须显示在需要定期更新的帖子中。因此,网站的管理员可以简单地在一个句子中输入新的更改日志,单击发布,它会在帖子中显示关于该软件的信息,从而创建一个包含更改日志的列表。
谢谢!
答
您可以使用下面的代码
<?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;