WordPress previous_posts_link()导致找不到404错误

时间:2009-03-18 12:40:12

标签: wordpress

以下是我正在使用的代码。我已经尝试了我能找到的所有东西,但仍然无效。我的永久链接结构是/%category%/%postname%/。我相信这个网址是正确的,它试图去http://localhost:8888/wordpress/blog/page/2。令人讨厌的是,完全相同的代码适用于我之前设计的另一个网站。

有人能指出我正确的方向吗?感谢

<?php get_header(); ?>
    <div id="content" class="narrowcolumn">
    <?php 
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts("cat=3&showposts=2&paged=" . $paged);

        $wp_query->is_archive = true; $wp_query->is_home = false;
    ?>

    <?php if (have_posts()) : ?>
    <div id="lefttop"></div>

    <div id="blogpoint">
    <div id="leftcol">
        <?php while (have_posts()) : the_post(); ?>

            <div id="leftsquidge">
                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2><br /><br />

                    <?php the_excerpt(); ?>
            </div>  
            <div id="rightsquidge">
                <?php the_tags( '<p><strong>File under:</strong> ', ', ', '</p>'); ?>
                <?php the_time('F jS, Y') ?>  by <strong><?php the_author() ?></strong>
            </div>
            <div style="clear:both;"></div> 
            <br /><br />
        <?php endwhile; ?>
        <div class="navigation" style="padding:0px;margin:0px;">
            <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
            <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
        </div>
    <?php endif; ?> 
        <div style="clear:both;"></div> 
        </div>

        </div>
        <div id="leftbot"></div>
    </div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

修改

我已经回答了我自己的问题。这是我之前尝试过的,但是没有用。您必须在仪表板上创建一个使用您的类别作为模板的页面。

2 个答案:

答案 0 :(得分:3)

尝试转到Wordpress管理员中的“阅读设置”,并确保“博客页面最多显示_帖子”设置为2,或者查询中的“showposts”限制。您的query_posts正在为您提供准确的结果,但Wordpress会根据您的阅读设置对其进行分页。

答案 1 :(得分:0)

如果相同的代码在其他网站中正常运行,请检查此网站的设置。比较两个站点上的永久链接设置。

网站是否在同一环境(Apache或iis)上工作?

相关问题