Created
August 28, 2011 19:38
-
-
Save chrisguitarguy/1177115 to your computer and use it in GitHub Desktop.
Add shortcodes back to auto generated excerpts in wordpress
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: Add Shortcodes (For WordPress Answers #27119) | |
Plugin URI: http://pmg.co/ | |
Description: Adds shortcodes to the excerpt | |
Version: 1.0 | |
Author: Christopher Davis | |
Author URI: http://pmg.co/people/chris | |
License: creative commons/GPL | |
*/ | |
add_filter( 'the_excerpt', 'do_shortcode' ); | |
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt', 10 ); | |
add_filter( 'get_the_excerpt', 'wpse27049_wp_trim_excerpt', 99, 1 ); | |
function wpse27049_wp_trim_excerpt( $text ) | |
{ | |
if ( '' == $text ) { | |
$text = get_the_content(''); | |
// $text = substr( $text, 0, 55 ) | |
} | |
return $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment