与我赤裸。首先,这是我的特色滑条文章的完整脚本:
<div id="featured" class="<?php if ( $responsive ) echo \'flexslider\' . $featured_auto_class; else echo \'et_cycle\'; ?>">
<a id="left-arrow" href="#"><?php esc_html_e(\'Previous\',\'Aggregate\'); ?></a>
<a id="right-arrow" href="#"><?php esc_html_e(\'Next\',\'Aggregate\'); ?></a>
<?php if ( $responsive ) { ?>
<ul class="slides">
<?php } else { ?>
<div id="slides">
<?php } ?>
<?php global $ids;
$ids = array();
$arr = array();
$i=0;
$featured_cat = get_option(\'aggregate_feat_cat\');
$featured_num = (int) get_option(\'aggregate_featured_num\');
if (get_option(\'aggregate_use_pages\') == \'false\') query_posts("showposts=$featured_num&top=billboard"); // set which slug in custom taxonomy TOP it should filter
else {
global $pages_number;
if (get_option(\'aggregate_feat_pages\') <> \'\') $featured_num = count(get_option(\'aggregate_feat_pages\'));
else $featured_num = $pages_number;
query_posts(array
(\'post_type\' => \'page\',
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'post__in\' => (array) get_option(\'aggregate_feat_pages\'),
\'showposts\' => (int) $featured_num
));
} ?>
<?php if (have_posts()) : while (have_posts()) :
global $post;
if (!$first_time) // START custom first post
{
$post_id = 105; // This is the ID of the first post to be displayed on slider
$post = get_post($post_id);
$first_time = 1;
}
else the_post(); // END custom first post
?>
<?php if ( $responsive ) { ?>
<li class="slide">
<?php } else { ?>
<div class="slide">
<?php } ?>
<?php
$width = $responsive ? 960 : 958;
$height = 340;
$small_width = 95;
$small_height = 54;
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,\'\',$titletext,$titletext,false,\'Featured\');
$arr[$i][\'thumbnail\'] = get_thumbnail($small_width,$small_height,\'\',$titletext,$titletext,false,\'Small\');
$arr[$i][\'titletext\'] = $titletext;
$thumb = $thumbnail["thumb"];
print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, \'\'); ?>
<div class="featured-top-shadow"></div>
<div class="featured-bottom-shadow feat<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>"></div>
<div class="featured-description">
<div class="feat_desc">
<h2 class="featured-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,20); ?></p>
</div>
</div> <!-- end .description -->
<?php if ( $responsive ) { ?>
</li> <!-- end .slide -->
<?php } else { ?>
</div> <!-- end .slide -->
<?php } ?>
<?php $ids[] = $post->ID; $i++; endwhile; endif; wp_reset_query(); ?>
<?php if ( $responsive ) { ?>
</ul> <!-- end .slides -->
<?php } else { ?>
</div> <!-- end #slides -->
<?php } ?>
</div> <!-- end #featured -->
It部门query_posts
自定义分类法中的一组帖子top=billboard
. 代码的以下部分:<?php if (have_posts()) : while (have_posts()) :
global $post;
if (!$first_time) // START custom first post
{
$post_id = 105; // This is the ID of the first post to be displayed on slider
$post = get_post($post_id);
$first_time = 1;
}
else the_post(); // END custom first post
?>
添加帖子ID105
返回列表的第一个帖子。这允许我控制首先显示哪个帖子。The problem is: If post ID105
已包含在自定义分类中top=billboard
, 然后它将在列表中出现两次。。。所以有一次,因为它是在上面添加的custom first post
一次,因为它是在自定义分类法中添加的top=billboard
.如何调整代码,以便在发布ID时105
存在于自定义分类中top=billboard
, 那么它应该not 出现两次(仅作为第一篇帖子)。