yuma-watanabe
12/21/2016 - 1:02 AM

タグにからピッカー指定して色つけるやーつ

タグにからピッカー指定して色つけるやーつ

<?php
if(have_posts()):
?>
					<ul class="ls_news bg-grid">
<?php
	while(have_posts()) : the_post();
	$terms = get_the_terms( get_the_ID(), 'topicscat');
	if($terms){
		$term = array_pop($terms);
		$tagColor = get_field('tag_color', $term );
	}
	$newFlg = get_field('new_flag');
?>
						<li class="clearfix">
							<a class="trans" href="<?php the_permalink(); ?>">
							<div class="date">
								<?php
								the_time('Y.m.d');
								if(is_post_type_archive('topicspost') || is_tax('topicscat')):
								?>
								<span class="tag" style="background-color: <?php echo $tagColor; ?>"><?php echo $term->name; ?></span>
								<?php endif; ?>
							</div>
							<div class="title">
								<?php if($newFlg == 'true'): ?>
									<span class="new_tag_txt">New</span>
								<?php endif; ?>
								<?php the_title(); ?>
							</div>
							</a>
						</li>
<?php
	endwhile;
?>
			</ul>
<?php
	pagination();
	wp_reset_postdata();
endif;
?>