Skip to content

Instantly share code, notes, and snippets.

@janisdonis
Created April 25, 2018 15:14
Show Gist options
  • Save janisdonis/c1916f4522f2b82f20f36114e4cecada to your computer and use it in GitHub Desktop.
Save janisdonis/c1916f4522f2b82f20f36114e4cecada to your computer and use it in GitHub Desktop.
Loop split
<ul>
<li><a href="#">Visas preces</a></li>
<?php
$childid = get_product_top_level_category ( get_the_ID());
$args = array(
'taxonomy' => 'product_cat',
'parent' => $childid
);
$terms = get_terms( $args );
$i = 1;
foreach( $terms as $term ) {
echo '<li><a href="'.get_term_link( $term->slug, 'product_cat' ).'">'. $term->name .'</a></li>';
if ($i == 10)
{ ?></li>
<li class="more dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Vairāk</a>
<div class="dropdown-menu">
<ul>
<?php }
$i++;
}
?>
</ul>
</div>
</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment