Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created March 13, 2017 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrasguseo/ddf3c8c6ac443f22c3af2afe0430d312 to your computer and use it in GitHub Desktop.
Save andrasguseo/ddf3c8c6ac443f22c3af2afe0430d312 to your computer and use it in GitHub Desktop.
Limit the number of words in the excerpt in Photo View
<?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