我的帖子在第二页重复了一遍

时间:2012-03-03 作者:Terrell Anderson

嘿,我对索引进行编码的方式是,它显示了一篇完整的文章,其余的文章都是摘录,但当我单击“上一页”时,第二页显示的是第一页的同一篇文章,我该怎么做才能改变这一点。

这是我的索引。php文件

                                                    <?php get_header() ?>

    <div id="content">          
 <?php if (have_posts()) : ?>
 <?php $count = 0; ?>

 <?php 
 query_posts(\'cat=0\'); while(have_posts()) : the_post(); 
 ?>
 <?php $count++; ?>

 <?php if ($count <= 1) : ?>


    <div class="entry-single">
            <div class="entry-top">

                <h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf( __(\'Permalink to %s\', \'wpbx\'), the_title_attribute(\'echo=0\') ) ?>" rel="bookmark"><?php the_title() ?></a></h2>

                <div class="entry-meta-top">
                    <span class="entry-date"><font color="#e60288"><b><?php echo human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') ) . \' ago\'; ?></b></font></span>
                    <span class="entry-meta-sep">|</span>
                    <span class="entry-cat">Published in <?php the_category(\',\'); ?> </span>

            </div>
 <div id="sharing">
 <span class=\'st_facebook_hcount\' st_title=\'<?php the_title(); ?>\' st_url=\'<?php          the_permalink(); ?>\' displayText=\'share\'></span><span class=\'st_twitter_hcount\'     st_title=\'<?php the_title(); ?>\' st_url=\'<?php the_permalink(); ?>\' displayText=\'share\'></span><span class=\'st_plusone_hcount\' st_title=\'<?php the_title(); ?>\' st_url=\'<?php the_permalink(); ?>\' displayText=\'share\'></span></div>
                </div>

            <div class="entry-content clearfix">
                <?php the_content(\'<p align="right"><b>Read More     »</b></p>\') ?>
                <?php wp_link_pages(\'before=<div class="page-  link">\' . __( \'Pages:\', \'wpbx\' ) . \'&after=</div>\') ?>
            </div>

               <div class="entry-meta entry-bottom">
  <?php the_tags( __( \'<span class="tag-links">More On: \', \'wpbx\' ), ", ", "</span>\\n" ) ?>

        <div id="footshare"><span class=\'st_facebook_hcount\' st_title=\'<?php      the_title(); ?>\' st_url=\'<?php the_permalink(); ?>\' displayText=\'share\'></span><span class=\'st_twitter_hcount\' st_title=\'<?php the_title(); ?>\' st_url=\'<?php the_permalink(); ?>\' displayText=\'share\'></span><span class=\'st_plusone_hcount\' st_title=\'<?php the_title(); ?>\' st_url=\'<?php the_permalink(); ?>\' displayText=\'share\'></span></div>

 <div id="footcomm"><span class="entry-comm"><?php comments_popup_link( __( \'Leave A Comment\', \'wpbx\' ), __( \'1 Reaction\', \'wpbx\' ), __( \'% Reactions\', \'wpbx\' ) ) ?></span></div>

            </div>

 <?php else : ?>


 <div class="entry">
        <div class="entry-top">



        </div>

            <div class="entry-content clearfix">

                <div class= "entry-list-thumb">
                    <a href="<?php the_permalink(); ?>" title="    <?php printf(__( \'Read %s\', \'wpbx\' ), wp_specialchars(get_the_title(), 1)) ?>">
                    <?php the_post_thumbnail(); ?>
                    </a>
                </div>

                <div class="entry-content">

 <h2 class="entry-title2"><a href="<?php the_permalink() ?>" title="<?php printf( __(\'Permalink to %s\', \'wpbx\'), the_title_attribute(\'echo=0\') ) ?>" rel="bookmark"><?php the_title() ?></a></h2>

 <div class="entry-meta-top">
                <span class="entry-date"><font color="#89f800"><b>     <?php echo human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') ) . \' ago\'; ?></b></font></span>
                <span class="entry-meta-sep">|</span>
                <span class="entry-comm">Published in <?php the_category(\', \'); ?></span>
            </div>

        <?php the_excerpt(); ?>



                </div>

            </div>



 <div class="entry-meta entry-bottom2">

<div id="footshare2"><a href="http://twitter.com/home?status=<?php the_title(); ?> http://celebloid.com/?p=<?php the_ID(); ?>" title="Share This Article On Twitter!" target="_blank"><img src="http://www.celebloid.com/wp-content/uploads/2012/02/twittershare.png"></a> <a href="http://www.facebook.com/sharer.php?u=<?php the_permalink() ?>" title="Share this on Facebook" target="_blank"><img src="http://www.celebloid.com/wp-content/uploads/2012/02/facebookshare.png"></a> <a class="addthis_button_email"><img src="http://www.celebloid.com/wp-content/uploads/2012/02/emailshare.png"></a> <a href="http://addthis.com/bookmark.php?v=250&amp;username=ra-4f481f3e69cf1512" class="addthis_button_compact"><img src="http://www.celebloid.com/wp-content/uploads/2012/02/moreshare.png"></a></div>

 <div id="footshare4"><?php the_tags( __( \'<span class="tag-links">More On: \', \'wpbx\' ), ", ", "</span>\\n" ) ?></div>

 <div id="footcommm"><span class="entry-more"><a href="<?php the_permalink() ?>" title="<?php printf(__(\'Continue reading %s\'), wp_specialchars(get_the_title(), 1)) ?>"><?php _e( \'<img src="http://www.celebloid.com/wp-content/uploads/2012/02/readmore.jpg">\', \'wpbx\' ) ?></a></span></div>

            </div>


 <?php endif; ?>
    </div><!-- .post -->

<?php endwhile; ?>

  <?php else : ?>
 <?php endif; ?>

        <div class="navigation clearfix">
            <div class="nav-previous"><?php next_posts_link(__( \'Previous <span class="meta-nav">Articles</span>\', \'wpbx\' )) ?></div>
            <div class="nav-next"><?php previous_posts_link(__( \'Next <span class="meta-nav">Articles</span>\', \'wpbx\' )) ?></div>

        </div>

    </div><!-- #content -->

 <?php get_sidebar() ?>
 </div>
 <?php get_footer() ?>
我之所以查询我的帖子,是因为我制作了一个自定义的特色内容幻灯片,它只从特定类别中获取帖子。

如果不查询帖子,它只从内容幻灯片上的类别中提取帖子。

1 个回复
SO网友:prionkor

将此代码改为查询帖子。参数“paged”用于跟踪分页,所以您必须在查询帖子上传递它。

$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$args = array(
                \'cat\' => 0,
                \'paged\' => $paged
                );
query_posts($args);
也尽量避免query_posts() 除非绝对必要。使用get_posts().

结束

相关推荐

Thesis -style Navigation

我正在研究一个主题,我希望用户能够像论文一样选择要在主题选项页面中显示的页面。我已经在谷歌上搜索了几个小时的逆向工程论文,但还没有找到一个很好的解决方案。我想知道是否有人做过这件事或看过教程。