Created
August 14, 2018 18:08
-
-
Save rotisoft/8a33fcb56a6faa78b9274b83a4949328 to your computer and use it in GitHub Desktop.
Woocommerce - Add sub categories list after description
This file contains 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
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>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CSS:
body .rssubcategories .subcatlastcssfix li { margin-bottom: 1em; }
@media (min-width: 768px) {
body .subcatlastcssfix li:nth-of-type(3n) { margin-right: 0px !important; }
}