Product category plugin
-
Hi
I have, with a code I found online and with a help from a friend (who is unavailable to me now) made a very small plugin that displays WooCommerce product child- and sibling-categories in a sidebar.What I need is a closing
ul tag in the right place. I don’t know php and don’t know where it is appropriate to have the html tags, but I think for sure I’m missing the /ul tag.Here is my function:
public function widget( $args, $instance ) { $term = get_queried_object()->term_id; $termid = get_term($term, 'product_cat' ); if($termid->parent > 0) { $args = array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'child_of' => $termid->parent, ); $siblingproducts = get_terms( 'product_cat', $args); ?><ul class="flokka-widget"><?php foreach ($siblingproducts as $siblingproduct) { if ($siblingproduct->term_id == $term ) { ?> <li class="currentterm"><a href="<?php echo get_term_link( $siblingproduct ); ?>"><?php echo $siblingproduct->name; ?></a></li> <?php } else { ?> <li><a href="<?php echo get_term_link( $siblingproduct ); ?>"><?php echo $siblingproduct->name; ?><!-- <?php echo "<span class='count'> (" . $siblingproduct->count . ")</span>"; ?> --></a></li> <?php } } } else { $args = array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'child_of' => $term ); $subproducts = get_terms( 'product_cat', $args); foreach ($subproducts as $subproduct) { ?> <li> <a href="<?php echo get_term_link( $subproduct ); ?>"><?php echo $subproduct->name; ?><!-- <?php echo "<span class='count'> (" . $subproduct->count . ")</span>"; ?> --></a></li> <?php } } }It is the ul with the class: flokka-widget that I need to close.
Hope someone can help 🙂
The topic ‘Product category plugin’ is closed to new replies.