Lista WooCommerce produktetiketter som ”knapplänkar” (inkl. rubrik, desc, img) på WooCommerce shopsida

Kan läggas i archive eller liknande mall

<?php 
	$page_id = get_queried_object_id();
	
	$terms = get_terms( array('product_tag') );

	if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ ?>
		<div class="editorial-wide spacing-top-x1">
			<h2 class="epsilon"><?php _e('Choose system', 'textdomain'); ?></h2>
			<div class="tag-button-group">
				<?php foreach ( $terms as $term ) {
					$show_term = get_field('show_on_product_archive', $term);
					
					if ($term->count > 0 && $show_term === true) {
					
						if ($term->term_id == $page_id) {
							$btn_classes = 'btn btn--content active current-menu-item';
						} else {
							$btn_classes = 'btn btn--content';
						}
						
						?>
							<button class="<?php echo $btn_classes ?>" href="<?php echo get_term_link($term->term_id); ?>">
								<div class="btn--content__image">
									<?php
										$image = get_field('tag_thumbnail', $term->taxonomy . '_' . $term->term_id);
										$size = 'thumbnail'; // (thumbnail, medium, large, full or custom size)
										if ( $image ) {
											echo wp_get_attachment_image( $image['ID'], $size );
										}
									?>
								</div>
								<div class="btn--content__text">
									<span class="btn--content__title"><?php echo $term->name; ?></span>
									<span class="btn--content__desc">
										<?php 
										$custom_desc = get_field('custom_description', $term->taxonomy . '_' . $term->term_id);
										if (!empty($custom_desc)) :
											echo $custom_desc;
										else :
											echo $term->description;
										endif;
										?>
									</span>
								</div>
							</button>
						<?php
						
					}
				} ?>
			</div><!-- .tag-button-group -->	
		</div><!-- .width -->
	<?php }
	

?>

Författare: Erik

Erik har jobbat med webb professionellt sedan 2008. Från 2005 till 2008 studerades webb på ING/JTH och dessförinnan skapades webb på all fritid. Första sajten byggdes någon gång mellan 1996-1998.