$product_cats = wp_get_post_terms(get_the_ID(), 'product_cat');
if ($product_cats) {
$deepestTerm = false;
$maxDepth = -1;
foreach ($product_cats as $cat) {
$termDepth = count(get_ancestors($cat->term_id, 'product_cat'));
if ($termDepth > $maxDepth) {
$deepestTerm = $cat;
$maxDepth = $termDepth;
}
}
echo $deepestTerm->term_id;
}
<?php the_post_thumbnail_url('shop_thumbnail'); ?>
global $post;
<?php echo get_the_post_thumbnail_url($post->ID, 'shop_thumbnail'); ?>
add_filter('gettext', 'dco_gettext', 20, 3);
function dco_gettext($translated_text, $text, $domain) {
switch ($translated_text) {
case 'Related Products' :
$translated_text = 'сопутствующие продукты';
break;
}
return $translated_text;
}
add_filter('gettext', 'dco_gettext', 20, 3);
function dco_gettext($translated_text, $text, $domain) {
switch ($text) {
case 'Related Products' :
$translated_text = 'сопутствующие продукты';
break;
}
return $translated_text;
}
Я немогу найти цикл здесь.
<?php global $i; $i = 0; while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php $i++; endwhile; // end of the loop. ?>
global $i; echo $i;