Я пытаюсь поместить элемент (краевую ленту) на определенные изображения термина в моем архиве. Я использую расширенные настраиваемые поля, чтобы присвоить значение определенным условиям. Однако в приведенном ниже коде помещается лента на КАЖДЫЙ термин, а не только на значение «active15». Может кто-нибудь помочь мне с тем, что я делаю неправильно?Применить элемент к фильтруемому значению ACF
В этом LINK показан образец того, что происходит. Алюминий - это единственный образ, который должен иметь ленту, но по какой-то причине кажется, что фильтр не применяется.
<!-- 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>
Можете ли вы добавить код, показывающий, как вы получаете '$ terms'? Также может помочь var_dump. – MSTannu
@MSTannu Да, см. Выше дополнение. – streetfire
Вы должны иметь '! == 'active15'' вместо'! = ' –