Я хочу получить все категории woocommerce с заголовком и изображениями.и после этого я хотел показать их на первой полосе.Предотвращение цикла foreach, потому что мой дизайн первой страницы похож на этот.[введите описание изображения здесь] [1]
<code> <?php
$termSlug = array();
$tax_terms = get_terms('product_cat', array('hide_empty' => '0'));
foreach ( $tax_terms as $tax_term ):
$termSlug[] = $tax_term->slug;
endforeach;
$args = array(
'post_type' => 'product', //Post type event
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $termSlug
)
)
);
// The Query
$the_query = new WP_Query( $args );
//echo '<pre>';print_r($the_query);echo "
"; if ($ the_query-> have_posts ()) {while ($ the_query-> have_posts ()) {$ the_query-> the_post ();?>Ничего не найдено [1]:
https://i.stack.imgur.com/A98em.jpg