在wordpress博客页面重复循环如何解决这个问题?

时间:2016-04-19 05:18:04

标签: php wordpress

如何在一个页面中仅列出10个帖子并解决分页,我在此发现了重复循环。

我也想在评论中应用css。我如何分离每个部分的评论,并可以给个人CSS?

    <?php query_posts('post_type=post&post_status=publish&posts_per_page=10&paged='. get_query_var('paged')); ?>

<?php if( have_posts() ): ?>

    <?php while( have_posts() ): the_post(); ?>

    <div id="post-<?php get_the_ID(); ?>" <?php post_class(); ?>>

        <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array(200,220),'thumbnail', array( 'class' => 'alignleft' ) ); ?></a>

            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

            <span class="meta"><?php //author_profile_avatar_link(48); ?> <strong><?php the_time('F jS, Y'); ?></strong> / <strong><?php the_author_link(); ?></strong> / <span class="comments"><?php comments_popup_link(__('0 comments','twentythirteen'),__('1 comment','twentythirteen'),__('% comments','twentythirteen')); ?></span></span>

    <?php the_excerpt(__('Continue reading »','twentythirteen')); ?>

        </div><!-- /#post-<?php get_the_ID(); ?> -->

    <?php endwhile; ?>

    <div class="navigation">
        <span class="newer"><?php previous_posts_link(__('« Newer','twentythirteen')) ?></span> <span class="older"><?php next_posts_link(__('Older »','twentythirteen')) ?></span>
    </div><!-- /.navigation -->

<?php else: ?>

    <div id="post-404" class="noposts">

        <p><?php _e('None found.','twentythirteen'); ?></p>

    </div><!-- /#post-404 -->

<?php endif; wp_reset_query(); ?>

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

0 个答案:

没有答案