how can i display in my theme all woocommerce category title are custom filed value.
example html like bellow
<li><a href="#">
<div>
<h2>category title</h5>
<h3>custom field one value</h6>
</div>
<div class="imgpos">custom field two value</div>
</a></li>
i tried many way but still not success
<?php
$post_type = 'product';
// Get all the taxonomies for this post type
$taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) );
foreach( $taxonomies as $taxonomy ) :
// Gets every "category" (term) in this taxonomy to get the respective posts
$terms = get_terms( $taxonomy );
foreach( $terms as $term ) :
$posts = new WP_Query( "taxonomy=$taxonomy&term=$term->slug&posts_per_page=2" );
if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post();
?>
<a href="<?php the_permalink(); ?>"><span><?php the_title(); ?></span></a><br><br>
<?php
endwhile; endif;
endforeach;
endforeach;
?>
UPDATE 1 bellow code only give me category title and link but can not figure out how to get costume filed value also
<?php
$args = array(
'number' => $number,
'orderby' => 'title',
'order' => 'ASC',
'hide_empty' => $hide_empty,
'include' => $ids
);
$product_categories = get_terms( 'product_cat', $args );
$count = count($product_categories);
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
echo '<h4><a href="' . get_term_link( $product_category ) . '">' . $product_category->name . '</a></h4>';
$args = array(
'posts_per_page' => -1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
// 'terms' => 'white-wines'
'terms' => $product_category->slug
)
),
);
}
}
?>
example for get custom value code will be bellow. i want fit that inside div
<?php if( get_field('hexagon_thumbnail') ): ?>
<img src="<?php the_field('hexagon_thumbnail'); ?>" />
<?php endif; ?>