- This topic has 8 replies, 3 voices, and was last updated 11 years, 5 months ago by Monica.
-
AuthorPosts
-
October 25, 2012 at 12:26 am #1349TanzytalesMember
Hey guys. I’d like to be able to display videos and images in post excerpts but I can’t where simplecatch strips html tags, or really anything much to do with excerpts except word length.
any help would be appreciated.
October 26, 2012 at 5:42 pm #1364SakinKeymaster@Tanzytales: The excerpt doesn’t display videos and images. It’s just a text. For excerpt length it can be any. You can setup it from Appearance -> Theme Options -> Theme Settings -> Excerpt / More Tag Settings.
October 27, 2012 at 4:23 am #1386TanzytalesMemberThere’s no way to prevent the theme from stripping other html tags from excerpts?
October 27, 2012 at 7:44 pm #1391TanzytalesMemberHalf solved this problem… got images and videos to show up but now there’s no continue reading link, heh.
October 27, 2012 at 8:13 pm #1393TanzytalesMemberThise code is the default. Seems to ignore html tags.
function wp_trim_excerpt($text = '') {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}This code allows other tags to be included in excerpts but I can’t figure out a way to make it work with simple catch’s excerpt_more…
function improved_trim_excerpt($text) { // Fakes an excerpt if needed
global $post;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace('\]\]\>', ']]>', $text);
$text = strip_tags($text, '');
$excerpt_length = 50;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
}
return $text;
}remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'improved_trim_excerpt');October 27, 2012 at 8:48 pm #1394TanzytalesMemberUpdate. Formulated a sultion.. it’s not the most elegent but it works 99%..
function improved_trim_excerpt($text) {
global $post;
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace('\]\]\>', ']]>', $text);
$text = strip_tags($text, '');
$excerpt_length = 40;
$words = explode(' ', $text, $excerpt_length + 1);
$text = force_balance_tags( $text );
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, 'ID) . '>' . 'Continue Reading...' . '');
$text = implode(' ', $words);
$text = force_balance_tags( $text );
}
}
return $text;
}remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'improved_trim_excerpt');I’m basically just styling my own read more link on the spot here.
The only problem I have with this is that tags may not close properlu due to the word limit leaving an open tag and breaking the continue reading link (possibly the rest of the page). This occured once but just changing the word limit bandaided the problem. Not the most ideal fix though.
As you can see I tried using force_balance_tags but it didnt seem to work.
I would also prefer to use simplecatch_excerpt_more in this function instead of adding this one in manually. Do you see any way for me to do that here?
November 11, 2012 at 4:34 am #1613MonicaMemberI have exactly the same problem.
Unfortunately I can not find a solution …
Which code is correct in the end? Where should I paste your code? Function.php?Help: (
November 11, 2012 at 4:19 pm #1870SakinKeymaster@Monica: We are sorry that the function you ask in beyond the scope and design and Simple Catch Theme. That is why you need to do the customization work. Each theme has it’s own scope and limitations.
November 12, 2012 at 2:11 am #1874MonicaMemberI advised myself 🙂
I used the DB-Excerpt plugin.
Everything works great 🙂 -
AuthorPosts
- The topic ‘Stop Stripping from Excerpts’ is closed to new replies.