Skip to content

Instantly share code, notes, and snippets.

@neilgee
Created October 27, 2018 06:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilgee/c0834345db048429e3efb8ff47e3478d to your computer and use it in GitHub Desktop.
Save neilgee/c0834345db048429e3efb8ff47e3478d to your computer and use it in GitHub Desktop.
<?php // <~ don't add me in
add_filter( 'woocommerce_short_description', 'prefix_filter_woocommerce_short_description' );
/**
* Limit WooCommerce Short Description Field
*/
function prefix_filter_woocommerce_short_description( $post_post_excerpt ) {
// make filter magic happen here...
if(! is_product() ) { // add in conditionals
$text = $post_post_excerpt;
$words = 10; // change word length
$more = ' […]'; // add a more cta
$post_post_excerpt = wp_trim_words( $text, $words, $more );
}
return $post_post_excerpt;
};
@beshealthcare
Copy link

I also just noticed that the function doesn't get applied to post items in loops outside the main loop e.g. 'related products' or 'recently viewed'. How could I apply it to them too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment