Created
March 9, 2017 17:34
-
-
Save mrwweb/0235f18da595eca8351e7c51512d274d to your computer and use it in GitHub Desktop.
A custom plugin to limit the length of excerpts *only* when they appear in Feature a Page Widget. (https://wordpress.org/plugins/feature-a-page-widget/) Save this file as `truncate-fpw-excerpt.php` and then place it in `/wp-content/mu-plugins/`. You may need to create this directory if it doesn't exist yet.
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 | |
/* | |
Plugin Name: Truncate Feature a Page Widget Excerpt | |
Description: Limits excerpt to 30 words. Ends cut-off excerpts with "..." | |
Version: 1.0 | |
Author: Mark Root-Wiley | |
Author URI: https://mrwweb.com | |
*/ | |
add_filter( 'fpw_excerpt', 'wp8887975_trim_fpw_excerpt' ); | |
function wp8887975_trim_fpw_excerpt( $excerpt ) { | |
$excerpt = wp_trim_words( $excerpt, 30, '…' ); | |
return $excerpt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment