将元素应用于过滤的ACF值


Apply Element to Filtered ACF value

我正试图在我的档案中的某些术语图像上放置一个元素(角带)。我正在使用高级自定义字段为某些术语赋值。然而,下面的代码在每个术语上都放置了一个功能区,而不仅仅是带有"active15"值的术语。有人能帮我做错事吗?

此链接显示了正在发生的事情的示例。铝是唯一应该有色带的图像,但由于某种原因,似乎没有应用过滤器。

      <!-- Green Ribbon for Top 15 Groups Start -->
              <?php    
      if($terms) {
        foreach($terms as $lc) {
        if( get_field('group_active_in_focus_15', 'focus15groups_'.$lc->term_id) != 'active15' ) continue; 
         {
        ?>
<div class="ribbon ribbon-green">
        <div class="banner">
            <div class="text">TOP 15</div>
        </div>
    </div>
                            <?php }      ?>

        <?php 
        }
    }

else 
{
    echo '<div class="ribbon ribbon-blue">
        <div class="banner">
            <div class="text">TOP 15</div>
        </div>
    </div>';
     }
?>
 <!-- Green Ribbon for Top 15 Groups End -->

获取/显示页面术语的代码

<div class="row">
                        <?php
                        if ( get_query_var( 'paged' ) ) {
                            $paged = get_query_var('paged');
                        }elseif( get_query_var( 'page' ) ) {
                            $paged = get_query_var( 'page' );
                        }else{
                            $paged = 1;
                        }
                        $per_page = 12;
                        #fix
                        $term_args = array(
                            'hide_empty'        => 0,
                             'exclude'           => array(16, 20, 22, 25, 27, 28, 30, 4, 33, 264 ), //* Enter ID's of parent categories to exclude from list 
                        );
                        $number_of_terms = wp_count_terms( 'focus15groups' , $term_args); // This counts the total number terms in the taxonomy with a function)
                        $paged_offset = ($paged - 1) * $per_page;
                        $libargs = array(
                            'orderby'           => 'name',
                            'order'             => 'ASC',
                            'exclude'          => array(16, 20, 22, 25, 27, 28, 30, 4, 33, 264 ), //* Enter ID's of parent categories to exclude from list 
                            'number'            => $per_page,
                            'offset'            => $paged_offset,
                        );  
                        $_libargs = wp_parse_args($term_args, $libargs);
                        $libcats = get_terms( 'focus15groups', $_libargs);  
                        #fix
                        $i = 0;
                        foreach($libcats as $lc){
                            if( $i % 4 == 0 ) { ?>
                                <div class="clearfix"></div>
                            <?php }
                            $i++; ?>
                            <div class="col-lg-3">
                                <?php $termlink = get_term_link( $lc->slug, 'focus15groups' ); ?>
                                <div class="panel panel-default <?php the_field('group_active_in_focus_15', 'focus15groups_'.$lc->term_id); ?>">
                <div class="panel-image">
                <!-- Green Ribbon for Top 15 Groups Start -->
              <?php    
      if($terms) {
        foreach($terms as $lc) {
        if( get_field('group_active_in_focus_15', 'focus15groups_'.$lc->term_id) != 'active15' ) continue; 
         {
        ?>
<div class="ribbon ribbon-green">
        <div class="banner">
            <div class="text">TOP 15</div>
        </div>
    </div>
                            <?php }      ?>

        <?php 
        }
    }

else 
{
    echo '<div class="ribbon ribbon-blue">
        <div class="banner">
            <div class="text">TOP 15</div>
        </div>
    </div>';
     }
?>
 <!-- Green Ribbon for Top 15 Groups End -->                    
 <?php if( get_field('group_active_in_focus_15', 'focus15groups_'.$term->term_id) != 'active15' )  { ?>
 <div class="ribbon ribbon-green">
        <div class="banner">
            <div class="text">TOP 15</div>
        </div>
    </div>
<?php } else { ?>
<?php } ?>

               <div class="thumbnail">
   <div class="caption">
                <br/><br/>   
                <h1><span class="label label-info"><?php echo  $lc->count  ?></span></h1>
                <p> Symbols </p>
                <h4> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </h4> 
            </div>
                    <!-- Get Image by Attachment ID Start-->
            <?php 
                $attachment_id = get_field('taximage', 'focus15groups_'.$lc->term_id);
                if ($attachment_id) {
                    $image = wp_get_attachment_image_src($attachment_id, 'industrygroup-img');
                    if ($image) {
                        ?>
                        <img class="img-responsive" src="<?php echo $image[0]; ?>" />
                        <?php 
                    } 
                } 
            else { ?>
<img class="img-responsive" src="http://www.runningalpha.com/wp-content/uploads/2014/08/RA-logo-300px-groups.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
</div>
            <!-- Get Image by Attachment ID End-->
                </div>
                                               <div class="panel-footer text-center"><a href="<?php echo $termlink; ?>"><?php echo $lc->name; ?></a>
                </div>
            </div>      
                            </div>
                      <?php }     ?>
                      </div>

我使用以下方法找到了一个修复程序。通过将我的代码移动到else语句,它显示了正确的术语。这似乎有点奇怪,但它运行得很好!

 <?php if( get_field('group_active_in_focus_15', 'focus15groups_'.$lc->term_id) != 'active15' )  { ?>
<?php } else { ?>
 <div class="ribbon ribbon-green">
        <div class="banner">
            <div class="text">TOP 15</div>
        </div>
    </div>
<?php } ?>