Set specific number of columns for top level term on product category archives


I’am a bit desperate about this issue im facing. I have tried so much o code tweaking, asking for help and nobody really could help me, maybe this is the place where some one could at least explain how to fix it.
So my task is to make [Main category] to fit 7 objects,products,categories or what ever you want to call them. And do not modify the rest sub-categories.
With some help i got this code:

 add_filter('loop_shop_columns', 'main_product_category_loop_columns', 999);
function main_product_category_loop_columns( $columns ) {
    if( ! is_product_category() )
        return $columns;
    $term = get_queried_object();

    if( $term && is_a($term, 'WP_Term') ) {
        return $term->parent > 0 ? $columns : 7;
    return $columns;

and here what i got:
it’s main category.

enter image description here

and here is sub-category. And the rest subcategories are untouched.
It’s probably a very little tweak needed to fix it. But after hours of trying blindly and not i could not make that happen. Maybe anyone can see the little mistake here ?
thanks in advance.
enter image description here

konstantinas ignas skutulas 2 months 0 Answers 7 views 0

Leave an answer