我设置了一个循环来显示每个项目都附加了两种分类法的项目。我的问题是,在循环中,我设置了一个功能来选择特定的帖子,为其附加不同的图像/样式,出于某种原因,这些帖子正在打印每个分类法,而不仅仅是与它们具体相关的分类法。循环中的其余帖子正在显示其正确的分类法。有什么线索吗?完整循环代码如下:
<?php $loop = new WP_Query( array( \'post_type\' => \'projects\', \'orderby\' => \'menu_order\', \'order\' => \'ASC\', \'showposts\' => 19 ) ); ?>
<?php
$c = 0;
while ( $loop->have_posts() ) : $loop->the_post();
$c++;
?>
<?php if( $c == 5 || $c == 15 || $c == 25 || $c == 35) : ?>
<li class="left-feature feature">
<span class="img">
<a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">
<?php
$rows = get_field(\'feature_image\');
if($rows)
{
foreach($rows as $row)
{
echo \'<img src="\' . $row[\'feature\'] . \'" alt=" " />\';
}
}
?>
</a>
</span>
<h2><?php the_title(); ?></h2>
<?php
$terms = get_terms(\'client\');
$count = count($terms);
if ( $count > 0 ){
echo "<p>Client: ";
foreach ( $terms as $term ) {
echo "<span>";
echo $term->name;
echo "</span>";
}
echo "</p>";
}
?>
<?php
$terms = get_terms(\'type\');
$count = count($terms);
if ( $count > 0 ){
echo "<p>Type: ";
foreach ( $terms as $term ) {
echo "<span>";
echo $term->name;
echo "</span>";
}
echo "</p>";
}
?>
</li>
<?php elseif( $c == 10 || $c == 20 || $c == 30 || $c == 40) : ?>
<li class="right-feature feature">
<span class="img">
<a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">
<?php
$rows = get_field(\'feature_image\');
if($rows)
{
foreach($rows as $row)
{
echo \'<img src="\' . $row[\'feature\'] . \'" alt=" " />\';
}
}
?>
</a>
</span>
<h2><?php the_title(); ?></h2>
<?php
$terms = get_terms(\'client\');
$count = count($terms);
if ( $count > 0 ){
echo "<p>Client: ";
foreach ( $terms as $term ) {
echo "<span>";
echo $term->name;
echo "</span>";
}
echo "</p>";
}
?>
<?php
$terms = get_terms(\'type\');
$count = count($terms);
if ( $count > 0 ){
echo "<p>Type: ";
foreach ( $terms as $term ) {
echo "<span>";
echo $term->name;
echo "</span>";
}
echo "</p>";
}
?>
</li>
<?php else : ?>
<li class="regular">
<span class="img">
<a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">
<?php
$rows = get_field(\'thumbnail_image\');
if($rows)
{
foreach($rows as $row)
{
echo \'<img src="\' . $row[\'thumbnail\'] . \'" alt=" " />\';
}
}
?>
</a>
</span>
<h2><?php the_title(); ?></h2>
<?php
$terms = get_the_terms($post->ID, \'client\');
echo \'<p>Client: \';
foreach ($terms as $taxindex => $taxitem) {
echo "<span>";
echo $taxitem->name;
echo "</span>";
}
echo \'</p>\'
?>
<?php
$terms = get_the_terms($post->ID, \'type\');
echo \'<p>Type: \';
foreach ($terms as $taxindex => $taxitem) {
echo "<span>";
echo $taxitem->name;
echo "</span>";
}
echo \'</p>\'
?>
</li>
<?php endif; endwhile; wp_reset_query(); ?>
</ul>