Home Forums WoodMart support forum Short Description on Shop Page

Short Description on Shop Page

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #548955

    shweta
    Participant

    Hello,

    I have added a short description on my store page. When someone clicks on the ellipsis, they will see the full description, which will be 8-10 words long. For better understanding, please find the attached screenshot.

    Best

    Attachments:
    You must be logged in to view attached files.
    #549045

    Hello,

    You are using the PHP code to show the short description in the shop page. You need to define the class in the PHP Code.

    Like this:

    add_action( 'woocommerce_after_shop_loop_item_title', 'pk_shop_product_short_description', 35, 2 );
    
    function pk_shop_product_short_description() {
        echo '<div class="shop-description">';
        the_excerpt();
        echo '</div>';
    }

    Then, add the following custom css code in the theme settings to control the description.

    .shop-description {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 3; /* Number of lines to show */
      -webkit-box-orient: vertical;
    }

    Best Regards.

    #549080

    shweta
    Participant

    Getting this error when i added this code.

    Error message:

    Cannot redeclare pk_shop_product_short_description() (previously declared in /home/u162792289/domains/akshatraghava.website/public_html/wp-content/themes/woodmart/functions.php:72)

    #549090

    Hello,

    Please remove the old code and add new one.

    Best Regards.

    #549091

    shweta
    Participant

    Which new code? have you shared the code?

    #549231

    Hello,

    Please remove the old code and add this code.

    add_action( 'woocommerce_after_shop_loop_item_title', 'pk_shop_product_short_description', 35, 2 );
    
    function pk_shop_product_short_description() {
        echo '<div class="shop-description">';
        the_excerpt();
        echo '</div>';
    }

    Best Regards.

    #549235

    shweta
    Participant

    Hello,

    I updated this code but still same issue.

    #549345

    Hello,

    After adding the PHP code, add the following custom css code in the theme settings to control the description.

    .shop-description {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 3; /* Number of lines to show */
      -webkit-box-orient: vertical;
    }

    Best Regards.

    #549357

    shweta
    Participant

    Still showing same issue, can you please check from your side i have already share the wp login details. please check its very urgent for me.

    #549396

    Hello,

    Now Check back your site and check the issue. You can set the Number of lines to show in for the sort description in the custom css code.

    Best Regards.

Viewing 10 posts - 1 through 10 (of 10 total)