В любой непонятной ситуации — дебажить надо. Построчно. Сверху вниз. Проверяя if-ы
так если выводить объект $term то там нет данного поля оно не подцепляется почему-то.
это в файле loop-start.php
вот весь код…может как то надо подцеплять данное поле иначе ?
<?php
/**
* Product Loop Start
*
* This template can be overridden by copying it to yourtheme/woocommerce/loop/loop-start.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<?php
$parentid = get_queried_object_id();
$args = array('parent' => $parentid);
$terms = get_terms( 'product_cat', $args );
$category = get_queried_object(); // получаем id категории
$itog = $category->term_id;
if ($itog === 193){
if ( $terms ) {
echo '<div class="categories_list categorypage brends clearfix">';
foreach ( $terms as $term ) {
echo '<div class="item">';
echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
?><div class="imgcat"><?php woocommerce_subcategory_thumbnail( $term ); ?></div><?php
echo '<span> '.$term->name.'</span>';
echo '</a>';
echo '</div>';
}
echo '</div>';
}
}
elseif ($itog === 20){
if ( $terms ) {
echo '<div class="categories_list categorypage seyfy clearfix">';
foreach ( $terms as $term ) {
echo '<div class="item">';
echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
woocommerce_subcategory_thumbnail( $term );
echo '<span> '.$term->name.'</span>';
echo '</a>';
echo '</div>';
}
echo '</div>';
}
}
elseif ($itog === 26){
if ( $terms ) {
echo '<div class="categories_list categorypage oruzheynye clearfix">';
foreach ( $terms as $term ) {
echo '<div class="item">';
echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
woocommerce_subcategory_thumbnail( $term );
echo '<span> '.$term->name.'</span>';
echo '</a>';
echo '</div>';
}
echo '</div>';
}
}
else
if ( $terms ) {
echo '<div class="categories_list categorypage clearfix">';
foreach ( $terms as $term ) {
echo '<div class="item">';
echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
woocommerce_subcategory_thumbnail( $term );
echo '<span> '.$term->name.'</span>';
echo '</a>';
echo '</div>';
}
echo '</div>';
}
?>
<ul class="products tovaryvkategorii columns-<?php echo esc_attr( wc_get_loop_prop( 'columns' ) ); ?>">
-
Ответ изменён 4 года, 5 месяцев назад пользователем morgusha.