WordPress   

Get all top level product categories including custom field and thumbnail

<div class="product-categories">
	<?php $productCats = get_terms('product_cat', array('hide_empty' => 0,'meta_key'   => 'order', 'orderby'    => 'meta_value_num', 'parent' =>0)); 
		foreach($productCats as $productCat) :
		//remove uncategorized from loop
		if( $productCat->slug == 'uncategorized' ){
           continue;
		}
		$productCategoryImage = wp_get_attachment_image( get_term_meta( $productCat->term_id, 'thumbnail_id', true ), 'full' );			
		?>
		<div class="product-category">
			<?php if($productCategoryImage): ?>
			<div class="product-category-img">
			<?php echo $productCategoryImage; ?>
			</div>
			<?php endif ?>
			<a class="product-category-title" href="<?php echo get_term_link( $productCat->slug, $productCat->taxonomy ); ?>"><?php echo $productCat->name; ?></a>
			<p class="product-category-text"><?php echo $productCat->description; ?></p>
			<p><?php the_field('category_subtitle'); ?></p>
		</div>
	<?php endforeach; ?>
</div>
Need Professional Support for Your Website Problems?

Whether you're facing website issues or struggling with code implementation, our team is here to assist. Hire us to get your website back on track.

Hire Us