Wordpress:如何在一个页面上放置2个不同的精选帖子

时间:2015-10-28 06:03:22

标签: php wordpress pagination

嗨我有一个问题就是在没有分页的情况下放置精选帖子,并在一个页面中添加分页帖子:

以下是我使用的第一个代码:

    <?php
          $sticky = get_option('sticky_posts');
          rsort( $sticky );
          $sticky = array_slice( $sticky, 0, 5);
          query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );

          if (have_posts()) : while (have_posts()) : the_post();
              $postImage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );
          ?>
              <div class="slider" style="background:url(<?php echo $postImage[0];?>) no-repeat center center">
                <div class="slider-shadowbox"></div>
                <a class="slider-hyperlink" href="<?php the_permalink(); ?>">
                <div class="slider-title">
                  <div class="featured-post-author">
                    <?php echo get_avatar( get_the_author_meta('user_email'), $size = '100'); ?>
                    <?php the_author_posts_link(); ?>
                  </div>
                  <span class="slider-tagline"><?php the_title()?></span>
                  <em class="slider-author">By <?php the_author_posts_link(); ?></em>
                  <em class="slider-date"><i class="fa fa-clock-o"></i> <?php the_time('F j, Y'); ?></em>
                </div>
                </a>
              </div>
          <?php
            endwhile;
          endif;
          ?>

/ 和第二个我使用它创建带分页的精选帖子,但不知何故,分页显示数字,但每个数字的超链接都无法正常工作。 /

<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    if ( have_posts() ) :

    while ( have_posts() ) : the_post(); ?>
      <div class="featured-post">
        <div class="zitem">
          <?php the_post_thumbnail( array(360, 240));?>
        </div>
        <span class="featured-post-summary">
          <h3><?php the_title(); ?></h3>
          <?php echo get_excerpt(); ?>
        </span>
        <div class="featured-post-author-wrap">
          <?php echo get_avatar( get_the_author_meta('user_email'), $size = '35'); ?>
          <span class="featured-post-author">By <?php the_author_posts_link(); ?></span>
          <span class="featured-post-date"><?php the_time('F j, Y'); ?><span>
        </div>
      </div>
    <?php endwhile; ?>
      <div class="featured-post-pagination pagination">
        <div class="pagination-outer"><?php my_pagination(); ?></div>
      </div>
    <?php else : ?>
      <strong>Sorry no post available.</strong>
    <?php endif; ?>

0 个答案:

没有答案