0
카테고리 이름이 포함 된 $project_cats
변수의 내용을 기반으로 CSS 클래스를 변경하려고합니다. $project_cats
은 내 스크립트 전체에서 유효하지만 내 if
문 중 하나에서 유효하지 않습니다. 적어도 내 가정은 맞습니다.가변 범위 Wordpress 쿼리
내 if
성명에서 $project_cats
에 액세스하려면 어떻게해야합니까?
<?php
if ($query->have_posts())
{
?>
<div id="myresource">
<?php
while ($query->have_posts())
{
$query->the_post();
?>
<?php
$terms = get_the_terms($post->id,"project-type");
$project_cats = NULL;
if (!empty($terms)){
foreach ($terms as $term) {
$project_cats .= strtolower($term->name) . ' ';
}
}
//$project_cats does not appear to have content in the below if statement
if ($project_cats == "webinars") {
$iconclass = "iconsmind-Video-4";
}
?>
<div class="nectar-icon-list" data-icon-color="default" data-icon-style="border" data-icon-size="small" data-animate="">
<div class="nectar-icon-list-item">
<div class="list-icon-holder" data-icon_type="icon" style="background-color:#1963af;">
<i class="icon-default-style <?php echo $iconclass; ?>" data-color="default"></i>
</div>
<div class="content">
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<?php the_excerpt(); ?>
<?php echo $project_cats;?>
</div>
</div>
</div>
<?php
}
?>
</div>
<?php
}
else
{
echo "No Results Found.";
}
?>