在不同的div中调用热门帖子

时间:2013-06-25 04:55:49

标签: php wordpress tags posts

我希望我的最新帖子显示所有信息(标题,作者,缩略图和内容),但只显示另一个div中第二个最新帖子的标题。这是我的代码。它正确渲染div,但第二个div中的'title'仍然是最新帖子的'title'。

                <div id="blog-pane">


        <div id="blog-post">

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



            <div id="post-title">

                <?php the_title(); ?>

            </div>

            <div id="post-author">

                <?php the_author(); ?>
                &nbsp;
                <?php the_date(); ?>
                &nbsp;
                <?php the_time(); ?>

            </div>

            <div id="post-image">

                <?php the_post_thumbnail(); ?>

            </div>

            <div id="post-text">

                <?php the_content(); ?>

            </div>      

        <?php endwhile; ?>
        <?php endif; ?>
        <?php rewind_posts(); ?>


        </div>


        <div id="post-link-1">

            <?php

                query_posts( 'p' );

                while ( have_posts() ) : the_post();

                the_title();

                endwhile;


                wp_reset_query();
                ?>
        </div>

    </div>

</div>

<?php get_footer(); ?>

1 个答案:

答案 0 :(得分:0)

您可以尝试引入一些跳过逻辑,让它跳过第一篇文章,

<div id="post-link-1">

            <?php

                query_posts( 'p' );
                $count = 0;
                while ( have_posts() ) { 

                       if ($count++ == 0) {
                           the_post();
                           continue;
                       }

                the_post();

                the_title();

                }


                wp_reset_query();
                ?>
        </div>