0

与其他帖子相比,最后一个置顶帖子总是具有不同的风格。我不明白如何在没有最后一个粘性的情况下显示所有帖子:(

我的代码:

<?php

$sticky = get_option('sticky_posts'); // show last sticky post
if (!empty($sticky)) {
  $args['post__in'] = $sticky;
  $qry = new WP_Query(array(    'posts_per_page' => 1, // yeah, last one
    'post__in'  => $sticky,
    'ignore_sticky_posts' => 1));
  if ($qry->have_posts()) :
    while ($qry->have_posts()) : $qry->the_post();?>

    <div class="blog-thumbs-sticky">
    <a class="sticky" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
              <div class="blog-thumb-title-sticky"><a class="green" href="<?php the_permalink(); ?>"><?php $thetitle = $post->post_title; $getlength = strlen($thetitle); $thelength = 157; echo mb_substr($thetitle, 0, $thelength, 'UTF-8'); if ($getlength > $thelength) echo "..."; ?></a></div>
              <div class="date-down"><?php the_date(' j F Y '); ?></div>
    <div class="blog-thumb-desc"><?php echo substr(get_the_excerpt(), 0,350); ?>...</div>
    </div>

    <?endwhile; endif;} ?>
<!-- Here I want to see all other posts -->
<?php
$sticky = get_option('sticky_posts');
$not_sticky = get_option('sticky_posts');
if (!empty($not_sticky)) {
  $args['post__not_in'] = $not_sticky;

  $nqry = new WP_Query(array(   'posts_per_page' => 6,
  'post__not_in' => array($sticky[0]), // how to delete newest sticky post, but show 2,3,4... sticky?
    'ignore_sticky_posts' => 0));

  if ($nqry->have_posts()) :
    while ($nqry->have_posts()) : $nqry->the_post();?>

    <div class="blog-thumbs-view-entry">

              <div class="blog-thumb-title"><a href="<?php the_permalink(); ?>"><?php $thetitle = $post->post_title; $getlength = strlen($thetitle); $thelength = 157; echo mb_substr($thetitle, 0, $thelength, 'UTF-8'); if ($getlength > $thelength) echo "..."; ?>123</a></div>
              <div class="date-down"><?php the_date(' j F Y '); ?></div>
    <div class="blog-thumb-desc"><?php echo substr(get_the_excerpt(), 0,130); ?>...</div>
    </div>

    <?endwhile; endif;} ?>

非常感谢。

4

1 回答 1

0

尝试通过添加来修改您的查询offset=1,它应该可以完成工作。

于 2013-07-29T21:06:32.833 回答