Site logo

[Resolved] Hide Product Short Description on Subcategories

Home Forums Support [Resolved] Hide Product Short Description on Subcategories

Home Forums Support Hide Product Short Description on Subcategories

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2581488
    Otger

    Hi!

    On Shop Main Page I show 4 categories with their descriptions (it is what I want).

    The problem comes when I enter a subcategory, which shows me all the short description of the product and I don’t want to show it.

    I have reviewed the post https://generatepress.com/forums/topic/displaying-the-description-of-a-product-category/#post-1701968 but it is not what I am looking for.

    Years ago I would have done such a thing in archive-product.php
    <?php /*echo apply_filters( ‘woocommerce_short_description’, $post->post_excerpt )*/ ?>
    <?php if (is_product_category()) { ?>

    <?php echo category_description(); ?>

    <?php } ?>

    But now there are only 5 hooks and I think I have to work with them.

    How can I disable the Product Short Description in subcategory pages through hooks? (And continue showing the description of the categories on the shop page)

    Thanks!

    #2581497
    Otger

    I have also tried this, but without success either:

    // Hide short product descriptions on subcategory pages
    add_action( ‘woocommerce_before_subcategory_title’, ‘remove_product_excerpt’, 1 );
    function remove_product_excerpt() {
    remove_action( ‘woocommerce_shop_loop_item_excerpt’, ‘woocommerce_template_single_excerpt’, 5 );
    }

    // Show category description on shop page (shop)
    add_action( ‘woocommerce_archive_description’, ‘show_category_description’, 5 );
    function show_category_description() {
    if ( is_product_category() && 0 !== absint( get_query_var( ‘paged’ ) ) ) {
    echo ‘

    ‘ . wpautop( term_description() ) . ‘

    ‘;
    }
    }

    #2581798
    David
    Staff
    Customer Support

    Hi there,

    try this:

    add_action( 'woocommerce_after_shop_loop_item_title', 'remove_short_description', 1 );
    function remove_short_description() {
        if ( is_product_category() ) {
            remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_single_excerpt', 5 );
        }
    }
    #2582472
    Otger

    Hi David,

    It works perfect! Thank you very much for the quick answer!

    #2582887
    David
    Staff
    Customer Support

    Glad to hear that!

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