Esther de Vries
Esther de Vries

Reputation: 13

Woocommerce: How do I show the product long description on the search page

When customers search for products right now, they'll see a line of Woocommerces code that is usually used to display the PDF file that has been uploaded to be shown on the product page. Like so;

Search example

Now what I want to achieve is to have the products long description show up for the search results instead of the long description.

So far I've managed to hide it all entirely to make it look presentable (compared to the code snippet) but I can not seem to figure out how to change it to the long description.

The long description can be used for all products so it doesn't have to check if the short description consists of words or code.

I've tried looking through the woocommerce settings but that hasn't done anything for me and in my post templates from woocommerce I can only find templates for the shop main pages and not for the search pages.

Upvotes: 1

Views: 5937

Answers (1)

Peter HvD
Peter HvD

Reputation: 1661

The template file that displays the products in the archive & search loop is content-product.php. What you're looking for is to insert the product's content into the woocommerce_after_shop_loop_item() hook.

function extra_description() { 
    global $post;
    echo '<div itemprop="description">';
        echo apply_filters( 'the_content', $post->post_content );
    echo '</div>';
}
add_action('woocommerce_after_shop_loop_item', 'extra_description', 1);

However, WooCommerce doesn't usually add the description to the loop, so you'll need to find what is currently adding it and remove that.

Upvotes: 3

Related Questions