• Resolved goodmuyis

    (@goodmuyis)


    I have search in find out to to add excerpt to WC product and how to limit it to frontpage product alone, also i see a recommedation in the use of is_featured() here

    But i dont understand how to use it, kindly help pls, below is my code

    add_action( 'woocommerce_after_shop_loop_item_title', 'ins_woocommerce_product_excerpt', 35, 2);
    if (!function_exists('ins_woocommerce_product_excerpt')){
    	function ins_woocommerce_product_excerpt(){
    		if(is_featured()){
    			if ( is_front_page() ) {
    				echo '<span class="excerpt">';
    				echo substr(get_the_excerpt(),0,115);
    				echo '</span>';
    			}
    		}
    	}
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey,

    Your code should look something like this

    add_action( 'woocommerce_after_shop_loop_item_title', 'ins_woocommerce_product_excerpt', 35, 2);
    if ( ! function_exists( 'ins_woocommerce_product_excerpt' ) ) {
    	function ins_woocommerce_product_excerpt(){
    		$product = new WC_Product( get_the_ID() );
    		if( $product->is_featured() ) {
    			if ( is_front_page() ) {
    				echo '<span class="excerpt">';
    				echo substr(get_the_excerpt(),0,115);
    				echo '</span>';
    			}
    		}
    	}
    }
    Thread Starter goodmuyis

    (@goodmuyis)

    Thanks for bailing me out Its Works

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘short excert in featured products’ is closed to new replies.