在网站上工作,我需要有一个单独的模板/页面才能显示该帖子。在其他模板/页面上显示一个帖子
在主页上(索引)Ill循环遍历我的类别并仅显示其中的一部分 - 事件 - 新闻 - 引用。
像这样:
<?php
$query = new WP_Query(array('category_name' => 'Events'));
if ($query->have_posts())
{
while ($query->have_posts()) : $query->the_post();
$haveEvents = true;
if ($eventCount < 3) {
$eventCount++;
?>
<div class="event-tile">
<div class="event-tile-content">
<h3><?php the_title(); ?></h3>
<h4><?php the_time('F jS, Y'); ?></h4>
<a href="<?php the_permalink(); ?>" class="event-tile-read-more">Lees meer</a>
</div>
</div>
<?php
}
endwhile;
}
我已经找到了如何显示一个类别中的所有职位分离页面上命名为:page-posts.php
On page-posts.php我只是检查我是哪个页面,并根据哪个页面进行查询以显示帖子内的内容指定类别现在我不能,如何显示在主页上(的index.php)单后,单后的网页上(甚至不花钱像谷歌时段后)计算出
$query;
if (is_page('events')) {
$query = new WP_Query(array('category_name' => 'Events'));
}
elseif (is_page('news')) {
$query = new WP_Query(array('category_name' => 'News'));
}
if ($query->have_posts())
{
etc..
。 ..
在我使用的操作按钮:
<a href="<?php the_permalink(); ?>" class="event-tile-read-more">Lees meer</a>
这让我回到主屏幕。 (刚开始使用Wordpress)
啊谢谢,这个作品,只是为了记录,我已经像几个小时左右Google搜索,所以非常感谢! –
顺便说一句,我现在使用两个,单一的只是一个类别中的所有职位的特定职位和网页发布! –