• I added a single product page element to my store homepage and I now need to hide the short product description on the homepage of my store. I have tried this code: remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20); but that just hides the short product description across the entire store.

    I will appreciate any snippet or CSS code that will fix this

Viewing 1 replies (of 1 total)
  • Hi!
    You are already on the right path its just that you have to hide the short product description from ONLY your homepage. I would suggest you to add the page id of pages from which you want to remove the short product description and you should be good to go.

    You can do this using the following code.
    Note that you have to change 5th line of this code snippet to customise this for your WooCommerce instance. For example, if your homepage id is 91, then that line should read as $pages_dont_display_excerpt = [ 91 ];

    
    add_action( 'the_post', 'remove_excerpt_from_page', 10, 1)  ;
    function remove_excerpt_from_page( $post ){
    
    	// REPLACE THIS LINE WITH YOUR HOMEPAGE ID.
    	$pages_dont_display_excerpt = [ 2 ];
    
    	$post_id = $post->ID;
    	if( in_array( $post_id, $pages_dont_display_excerpt ) ){
    		remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
    	}	
    }
    

    If you do-not know how to find page id, refer https://www.elegantthemes.com/blog/tips-tricks/how-to-find-your-wordpress-page-id-and-post-id-and-what-you-can-do-with-them

Viewing 1 replies (of 1 total)
  • The topic ‘Hide short product description’ is closed to new replies.