Answer the question
In order to leave comments, you need to log in
How to output slug from product_cat as text in wordpress loop?
It is necessary to display information from slug (label) from product_cat (Products->Categories, Wordpress) as text in order for Cyrillic tabs on the site page to work correctly. I broke my whole head, but I can’t figure out how to do it. Output should be in this place: href="# after the # element. The current code drags the name of the category.
<div class="row">
<div class="col-12">
<ul class="nav tab-navigation justify-content-center">
<?php
$i = 1;
if (is_array($product_cat)) {
foreach ( $product_cat as $value ) {
if($i <= 20) {
// $category[] = $value->slug;
if( $i == 1 ){ ?>
<li class="nav-item">
<a class="nav-link active" href="#<?php echo $value;?>" data-toggle="pill"><?php echo $value;?></a>
</li>
<?php }else{ ?>
<li class="nav-item">
<a class="nav-link" href="#<?php echo $value;?>" data-toggle="pill" ><?php echo $value;?></a>
</li>
<?php }
}
$i++;
}
# code...
}
?>
</ul>
</div><!--/.col-12-->
<div class="col-12">
<div class="tab-content" id="pills-tabContent">
<?php
$i=1;
if (is_array($product_cat)) {
foreach ($product_cat as $value) {
if( $i == 1){ ?>
<div class="tab-pane fade show active" id="<?php echo $value;?>">
<?php }else{?>
<div class="tab-pane fade" id="<?php echo $value;?>">
<?php } $i++; ?>
<?php
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question