• Resolved tdutkowski

    (@tdutkowski)


    Hello,
    Im looking for solution How to add custom code above category description?

    I found this code but it doesn’t work

    remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10, 2 );
    remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10, 2 );
    
    add_action( 'woocommerce_archive_description', 'ts_add_to_category_description' );
    function ts_add_to_category_description() {
    if ( is_product_category()) {
    $cat_desc = term_description( $cat_id, 'product_cat' );
    echo 'test'.$cat_desc;
    }
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @tdutkowski ,

    The code is fine reason for not working is, in first line you are using remove_action, then it will remove the action ‘woocommerce_archive_description’, then it will not be able to call it’s callback function.

    That’s why it is not working, simply use this snippet in your active theme’s functions.php(child theme),

    add_action( 'woocommerce_archive_description', 'ced_category_description' );
    
       function ced_category_description() {
           if ( is_product_category()) {
       echo 'Your text here:';	
       }
     }

    Thanks & Regards,

    • This reply was modified 4 years, 8 months ago by cedcommerce.
    Thread Starter tdutkowski

    (@tdutkowski)

    Hello,
    I use you code check it out https://www.beta.apautomatyka.pl/produkty/automatyka/przetworniki/
    Text appear but in <head>. Look at source code.

    I need my code to appear above “Przetworniki Wilgotno?ci” text.

    @tdutkowski – It looks like you may have already figured this out. Can you verify if this is something you’re still needing assistance with?

    Thread Starter tdutkowski

    (@tdutkowski)

    Yes i figured it out ?? no help needed

    Glad to hear that! Feel free to create a new thread if you have any other issues. ??

    Have a nice and safe day,
    Joey

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add custom code above category description’ is closed to new replies.