Last active
December 18, 2015 23:39
-
-
Save noahbass/5862967 to your computer and use it in GitHub Desktop.
Better WordPress Excerpts
This file contains hidden or 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 | |
| // better WordPress excerpts | |
| // Usage: echo get_excerpt(250); (replace 250 with the number of characters) | |
| function get_excerpt($count) { | |
| $excerpt = get_the_content(); | |
| $excerpt = strip_tags($excerpt); | |
| $excerpt = strip_shortcodes($excerpt); | |
| $excerpt = substr($excerpt, 0, $count); | |
| $excerpt = rtrim($excerpt, '.'); | |
| $excerpt = rtrim($excerpt, ' '); | |
| $excerpt = $excerpt.'...'; | |
| return $excerpt; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment