Created
March 4, 2012 07:24
-
-
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
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 /* | |
* 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( ']]>', ']]>', $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