Created
June 1, 2017 13:26
-
-
Save artikus11/ccdb842abe929ac10b022f491eb52a60 to your computer and use it in GitHub Desktop.
Разделение родительской и дочерних рубрик
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cat_product_wer = get_the_terms ($product->get_id(), 'product_cat'); | |
if ( $cat_product_wer ) { | |
$res = ''; | |
$child_id = ''; | |
$author = ''; | |
$authorLink = '#'; | |
$series = []; | |
foreach ( $cat_product_wer as $term ) { | |
if ($term->parent == 0) { | |
$author = $term->name; | |
$authorLink = $term->name; | |
} else { | |
$series[] = array( | |
'name' => $term->name, | |
'link' => get_term_link($term->term_id,'product_cat' ), | |
); | |
} | |
?> | |
<?php } ?> | |
<?php if ($author) { ?> | |
<div class="posted_in"> | |
<span>Автор: </span> | |
<a href="<?php echo $authorLink; ?>"> | |
<?php echo $author; ?> | |
</a> | |
</div> | |
<?php } ?> | |
<?php if ($series) {?> | |
<div class="posted_in"> | |
<span>Серия: </span> | |
<?php foreach ($series as $seriesOne) {?> | |
<a href="<?php echo $seriesOne['link']; ?>"> | |
<?php echo $seriesOne['name']; ?> | |
</a> | |
<?php }?> | |
</div> | |
<?php }?> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment