Wordpress“阅读更多”无效

时间:2010-02-28 08:37:01

标签: wordpress

我在我正在处理的网站的首页上使用了两个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 &raquo;'); 
    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 &raquo;'); 
    endwhile;
?>
</div>

你能看出我做错了吗?

1 个答案:

答案 0 :(得分:2)

如果您想要阅读更多内容,那么我会使用the_excerpt,因为这是您的内容中较短的内容,或者您​​可以使用此内容:

<a href="<?php the_permalink(); ?>" title="Read More">Read More &raquo;</a>
在你的例子中

...

$more = 0;

echo get_content().'<a href="'.get_permalink().'" title="Read More">Read More &raquo;</a>'; 

endwhile;