Created
March 13, 2017 22:39
-
-
Save andrasguseo/ddf3c8c6ac443f22c3af2afe0430d312 to your computer and use it in GitHub Desktop.
Limit the number of words in the excerpt in Photo View
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
<?php | |
/* | |
* Limit the number of words in the excerpt in photo view | |
* For Events Calendar Pro | |
* Last update: March 13, 2017 | |
* Last version checked: ECPro 4.4.4 | |
* Author: Barry Hughes | |
*/ | |
function photo_view_excerpt_length_init( $passthru ) { | |
if ( tribe_is_photo() ) { | |
add_filter( 'excerpt_length', 'photo_view_excerpt_length', 1000 ); | |
} | |
return $passthru; | |
} | |
function photo_view_excerpt_length() { | |
remove_filter( 'excerpt_length', 'photo_view_excerpt_length', 1000 ); | |
return 5; // Adjust this number for the number of words wanted in the excerpt | |
} | |
add_filter( 'tribe_events_excerpt_allowed_html', 'photo_view_excerpt_length_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment