Skip to content

Instantly share code, notes, and snippets.

@rotisoft
Created August 14, 2018 18:08
Show Gist options
  • Save rotisoft/8a33fcb56a6faa78b9274b83a4949328 to your computer and use it in GitHub Desktop.
Save rotisoft/8a33fcb56a6faa78b9274b83a4949328 to your computer and use it in GitHub Desktop.
Woocommerce - Add sub categories list after description
add_action( 'woocommerce_archive_description', 'rs_woo_category_description' );
function rs_woo_category_description() {
$parentid = get_queried_object_id();
$args = array( 'parent' => $parentid);
$terms = get_terms( 'product_cat', $args );
if ( $terms ) {
echo '<hr>';
echo '<div class="rssubcategories">';
echo '<h2>Alkategóriák</h2>';
echo '<ul class="products columns-3 subcatlastcssfix">';
foreach ( $terms as $term ) {
echo '<li class="product-category product">';
echo '<h2>';
echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
echo $term->name;
echo '</a>';
echo '</h2>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
echo '<hr>';
}
}
@rotisoft
Copy link
Author

CSS:

body .rssubcategories .subcatlastcssfix li { margin-bottom: 1em; }
@media (min-width: 768px) {
body .subcatlastcssfix li:nth-of-type(3n) { margin-right: 0px !important; }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment