0
我循环通过定义的类别中的前几个职位,第一个是从其余的分开,但第一个然后仍然包括在内。我需要$ i号码2等,不要包含已显示的第一个帖子。独立的第一篇文章,并忽略重复
我推测在$我有某种休息。我尝试将$ i切换为2,作为我现在玩的初学者。
<div class="article-block-v1">
<?php
//get terms (category ids 11,2,33,34), then display one post in each term
$taxonomy = 'category';// e.g. post_tag, category
$param_type = 'category__in'; // e.g. tag__in, category__in
$term_args=array(
'include' => '1459',
'orderby' => 'date',
'order' => 'DESC'
);
$terms = get_terms($taxonomy,$term_args);
if ($terms) {
foreach($terms as $term) {
$args=array(
"$param_type" => array($term->term_id),
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 3,
);
$my_query = null;
$my_query = new WP_Query($args);
$i = 1;
if($my_query->have_posts()) {
echo '<ul>';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php if ($i == 1): ?>
<div class="article-block-v1">
<div class="category-label-large category-news-analysis">
<a href="<?php the_permalink(); ?>"><p><?php echo $term->name; ?></p></a>
</div>
<div class="view2 third-effect">
<?php the_post_thumbnail(); ?>
<div class="mask">
<a href="<?php the_permalink() ?>" class="info" ><i class="fa fa-search"></i></a>
</div>
</div>
<ul class="homepagewhitebg">
<li><h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5></li>
</ul>
</div>
<?php $i = 2; ?>
<?php endif; ?>
<li><a href="<?php the_permalink(); ?>"><p><?php the_title(); ?></p></a></li>
<?php
$i++;
endwhile;
echo '</ul>';
}
}
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>