• Resolved sintarta

    (@sintarta)


    Hi

    Is there a way, a function maybe, to remove on fly, a prefix from category name?

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Jeff Alvarez

    (@superlemon1998)

    Hi @sintarta ,

    I’m note quite following what you mean by removing the prefix from the category name. Can you please provide more information and/or a screenshot so I can get a better idea?

    Thread Starter sintarta

    (@sintarta)

    I mean, what if my categories names start with, for some reason, el-category, and i want to remove el-, when create xml file..

    Thank you for your help

    Plugin Support Tanjir Al Mamun

    (@tanjiralmamun)

    Hello @sintarta,

    Add the following code snippet at the bottom of your child theme’s functions.php file to remove prefixes from your category. If you do not have a child theme, you can utilize the WPCode plugin.

    #== Truncate Text from Category Attribute ==#
    function truncate_category_attribute_values( $product_data, $feed, $product ) {
    if( isset( $product_data[ 'category_path' ] ) ) {
    $truncate_cats = str_replace( "Ab - ", "", $product_data[ 'category_path' ] ); // replace "Ab - " with your prefix
    $product_data[ 'category_path' ] = $truncate_cats;
    }

    return $product_data;
    }
    add_filter( 'adt_get_product_data', 'truncate_category_attribute_values', 10, 3 );

    This code will remove the prefix if you’ve mapped the Category Path attribute. However, if you’ve mapped the Category Path Short attribute instead, replace category_path with category_path_short in the code.

    Cheers!

    Thread Starter sintarta

    (@sintarta)

    With some modifications, is working

    Thank you, i appreciate a lot

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.