Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created May 18, 2015 17:18
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 generatepress/d219381b78e9732b17c0 to your computer and use it in GitHub Desktop.
Save generatepress/d219381b78e9732b17c0 to your computer and use it in GitHub Desktop.
Change the excerpt length on search results only. Requires Generate Blog to be enabled.
if ( ! function_exists( 'generate_excerpt_length' ) ) :
add_filter( 'excerpt_length', 'generate_excerpt_length', 999 );
function generate_excerpt_length( $length ) {
$generate_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( is_search() ) :
return 100;
else :
return $generate_settings['excerpt_length'];
endif;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment