• Resolved Rex AZ

    (@rexyspy)


    Hi,

    I want to add the excerpt element of a product to the woocommerce archive or shop page, as obtainable/seen on the single product product page.

    Let me break down the structure as it is available on the theme. But am concerned with the archive page only:

    The Single Product Page elements has:
    1. Title
    2. Image
    3. Excerpt
    4. Product Meta
    5. Price
    6. Quantity & Add to Cart

    The Archive Product Page elements has:
    1. Title
    2. Image
    3. Category
    4. Description
    5. Price/Rating
    6. Add to Cart
    7. I want to add excerpt here as seen above, but it is not available. How do I achieve this?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    Can you share your site link?

    add_action( ‘ocean_after_archive_product_add_to_cart’, ‘custom_after_addtocart’ );
    function custom_after_addtocart() {

    global $product;

    if ( $product->get_short_description() ) {
    echo $product->get_short_description();
    }

    }
    add this in your fucntion.php file

    Thread Starter Rex AZ

    (@rexyspy)

    Thanks likipadhy. But I tried it, it didn’t work.
    Amit, here is my site link https://iauctionx.com.

    Hello,

    Try adding below code in the functions.php file of the child theme. The below code display description below the title but you can change the location. You can find hooks in the OceanWP Theme > Woocoomerce folder. Open a file e.g owp-archive-product.php file and find a hook where you want to display the description.

    function display_desc_in_product_archives() {
       the_excerpt();
    }
    add_action( 'ocean_after_archive_product_title', 'display_desc_in_product_archives' );
    Thread Starter Rex AZ

    (@rexyspy)

    Perfect as usual Amit.

    I put it under the product image, so I had the code as shown below:

    function display_desc_in_product_archives() {
       the_excerpt();
    }
    add_action( 'ocean_after_archive_product_image', 'display_desc_in_product_archives' );
    

    Thank you Amit.

    You’re welcome!

    Hi,

    Do you know how to limit the Excerpt?

    I try this code below but it doesn’t work.

    function wpdocs_custom_excerpt_length( $length ) {
        return 2;
    }
    add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to Add Excerpt to Woocommerce Archive Page’ is closed to new replies.