• Resolved Piotr Zalog

    (@znawca-kaszanki)


    Hi,

    Filter widget is placed on narrow sidebar. Names of categories are very long and take two or more lines, which makes sidebar ugly.
    http://wstaw.org/m/2018/01/03/2018-01-03_17h47_37.png

    I want to create additional custom field for categories called ‘short_sidebar_name’ and load it in place of normal category name. But I don’t know which file I should edit. Can you help me?

    PS. I know I will have to corect it after every update, but it is not my decision.

Viewing 1 replies (of 1 total)
  • Thread Starter Piotr Zalog

    (@znawca-kaszanki)

    OK,

    I have done:
    0. I’ve created custom field with Advanced Custom fields plugin.
    1. File to modify was \wp-content\plugins\woocommerce-products-filter\views\html_types\checkbox.php
    2. Code looks like (starts in 204-th line):

    //before changes: echo $term['name'];
    //after:
    if( class_exists('acf') ) {
    $woo_cat_number = 'product_cat_'.$term['term_id'];
    $woo_brand_number = 'pwb-brand_'.$term['term_id'];
    $cat_krotka_nazwa = get_field('krotka_nazwa',$woo_cat_number);
    $brand_krotka_nazwa = get_field('krotka_nazwa',$woo_brand_number);
    if (($cat_krotka_nazwa=='') and ($brand_krotka_nazwa=='')){
    echo $term['name'];
    }else{
    echo $cat_krotka_nazwa;
    echo $brand_krotka_nazwa;
    }
    }else{
    echo $term['name'];
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Too long category name – how to replace it by custom field.’ is closed to new replies.