Created
June 24, 2016 13:36
-
-
Save sonnetmia/7a8dad2af9beab24f53e76638d1c5838 to your computer and use it in GitHub Desktop.
Woocommerce Post Excerpt Lenght Control For Short Description
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function string_limit_words($string, $word_limit) | |
{ | |
$words = explode(' ', $string, ($word_limit + 1)); | |
if(count($words) > $word_limit) | |
array_pop($words); | |
return implode(' ', $words); | |
} | |
function hook_some_content_into_content_product_page(){ | |
$excerpt = get_the_excerpt(); | |
$limitedcontent = strip_tags($excerpt); | |
echo '<p class="homeexcerpt">'.string_limit_words($limitedcontent,10).'</p>'; | |
return true; | |
} | |
add_action('woocommerce_after_shop_loop_item_title', 'hook_some_content_into_content_product_page' , 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment