Created
May 18, 2015 17:18
-
-
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.
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
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