Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Replaces the title of a review with the first few words of the review text
- * @param object $review
- * @return object
- */
- add_filter( 'site-reviews/get/review', function( $review ) {
- $limit = 6; // change this number to the desired number of words
- $split = 0;
- if( str_word_count( $review->content, 0 ) > $limit ) {
- $words = array_keys( str_word_count( $review->content, 2 ));
- $split = $words[$limit];
- }
- $review->title = substr( $review->content, 0, $split );
- return $review;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement