Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Created August 28, 2011 19:38
Show Gist options
  • Save chrisguitarguy/1177115 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/1177115 to your computer and use it in GitHub Desktop.
Add shortcodes back to auto generated excerpts in wordpress
<?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