我在我正在处理的网站的首页上使用了两个wp查询。他们各自检索一个帖子。第一个查询获取“新闻”类别中的最新帖子,第二个查询获取博客中的最新帖子,不包括“新闻”类别。
这很好用。
然而,我似乎无法让“阅读更多”工作。是因为我不使用标准查询吗?
<div class="column_left">
<h3>Fresh news</h3>
<p><span class="date"><?php the_time('j F, Y') ?>. Timed <?php the_time('G:i') ?></span></p>
<?php
$news = new WP_Query('cat=19&showposts=1');
while ( $news->have_posts() ):
$news->the_post();
global $more;
$more = 0;
the_content('Read more »');
endwhile;
?>
</div>
<div class="column_right">
<h3>Collected from the blog</h3>
<?php
$blog = new WP_Query('cat=-19&showposts=1');
while ( $blog->have_posts() ):
$blog->the_post();
global $more;
$more = 0;
the_content('Read more »');
endwhile;
?>
</div>
你能看出我做错了吗?
答案 0 :(得分:2)
如果您想要阅读更多内容,那么我会使用the_excerpt,因为这是您的内容中较短的内容,或者您可以使用此内容:
<a href="<?php the_permalink(); ?>" title="Read More">Read More »</a>
在你的例子中:
...
$more = 0;
echo get_content().'<a href="'.get_permalink().'" title="Read More">Read More »</a>';
endwhile;