0
我想链接wordpress中的帖子。让我详细说明一下。在wordpress中,你可以设置你想在页面上显示多少帖子。例如,如果您将该数字设置为1,并且您有10个帖子,则您将拥有10个页面。在wordpress中的链接帖子
我有以下代码在index.php(主帖子页)工作。它显示了旧帖子的链接。下面是代码:
<ul id="postNavigation">
<li class="floatLeft"><?php next_posts_link('Old posts »') ?></li>
<li class="floatRight"><?php previous_posts_link('« New posts') ?></li>
</ul>
现在,我有我的WordPress的设置方式,我还有一个网页,我展示使用这种代码的某一类别的职位(这个代码是在我的page.php文件的文件):
<?php if (is_page('newspaper')) { // BEGINNING of newspaper page
?>
<?php $my_query = new WP_Query('category_name=newspaper'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="post">
<!--<h3><?php the_title(); ?></h3>-->
<?php the_content('Read the rest of this entry »'); ?>
<div class="clear"></div>
</div>
<?php endwhile; ?>
<ul id="postNavigation">
<li class="floatLeft"><?php next_posts_link('Old Posts »') ?></li>
<li class="floatRight"><?php previous_posts_link('« New Posts') ?></li>
</ul>
<?php } //END of newspaper page
?>
但是,它并没有显示那里的“旧帖子”链接。有没有人有任何想法,以及如何实现这一目标?
感谢, 阿米特
嗯..我认为这两个链接都失踪了。我不确定。你怎么会认为只有更老的人失踪? – Amit 2010-08-06 07:30:07
当我把后导航链接,只是没有生成。如果我设置wordpress每页显示1篇文章,并且有10篇文章,则表示其中9篇文章不会显示(没有机会导航到他们)。我不确定这是否可以解决,因为这不是处理index.php文件,而是处理page.php文件(因为这不是博客的主页面,也就是is_home(),这是一个is_page() )如果这对你有任何意义...)Soo ..现在,我只是将它设置为posts_per_page = -1,以便所有帖子都显示在该页面上。 – Amit 2010-08-06 07:32:37
如果您有任何建议,我很乐意听到他们。现在,我也会试一试你的代码。 – Amit 2010-08-06 07:32:55