Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1349
    Tanzytales
    Member

    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.

    #1364
    Sakin
    Keymaster

    @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.

    #1386
    Tanzytales
    Member

    There’s no way to prevent the theme from stripping other html tags from excerpts?

    #1391
    Tanzytales
    Member

    Half solved this problem… got images and videos to show up but now there’s no continue reading link, heh.

    #1393
    Tanzytales
    Member

    Thise 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');

    #1394
    Tanzytales
    Member

    Update. 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?

    #1613
    Monica
    Member

    I 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: (

    #1870
    Sakin
    Keymaster

    @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.

    #1874
    Monica
    Member

    I advised myself 🙂
    I used the DB-Excerpt plugin.
    Everything works great 🙂

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Stop Stripping from Excerpts’ is closed to new replies.