Skip to content

Instantly share code, notes, and snippets.

@BronsonQuick
Created March 4, 2012 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BronsonQuick/1971124 to your computer and use it in GitHub Desktop.
Save BronsonQuick/1971124 to your computer and use it in GitHub Desktop.
Extract the_content in WordPress but only bring back links and <strong> tags
<?php /*
* Sometimes you will might want something like the_excerpt but still want <strong> tags. Add this function and call it
* inside your theme template file e.g. sennza_enhanced_excerpt();
*/
function sennza_enhanced_excerpt( $content ) {
$content = strip_shortcodes( $content );
$content = str_replace( ']]>', ']]&gt;', $content );
$content = preg_replace( '/<img[^>]+./','',$content );
$content = preg_replace( '%<div.+?</div>%is', '', $content );
$content = preg_replace( '%<object.+?</object>%is', '', $content );
$content = preg_replace( '/<blockquote>/is', '', $content );
$content = preg_replace( '%<table.+?</table>%is', '', $content );
return $content;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment