WordPress.org

Ready to get started?Download WordPress

Forums

Recent Posts Widget Extended
[resolved] Preserve HTML tags in the excerpt (8 posts)

  1. Sandra
    Member
    Posted 1 year ago #

    I would like to preserve the html tags of my post.

    I'm not sure if i should change something in my own wordpress files or in your php file on line 380

    (i'm no php expert :-) )

    function rpwe_excerpt( $length ) {

    $excerpt = explode( ' ', get_the_excerpt(), $length );
    if ( count( $excerpt ) >= $length ) {
    array_pop( $excerpt );
    $excerpt = implode( " ", $excerpt );
    } else {
    $excerpt = implode( " ", $excerpt );
    }
    $excerpt = preg_replace( '\[[^\]]*\]', '', $excerpt );

    return $excerpt;

    }

    http://wordpress.org/plugins/recent-posts-widget-extended/

  2. Satrya
    Member
    Plugin Author

    Posted 1 year ago #

    Hmmm.. it's a bit complicated, why you need to display the html tag in excerpt?

  3. Sandra
    Member
    Posted 1 year ago #

    I'd like to have the same styling, paragraphs, use bold type as in the article.

  4. Satrya
    Member
    Plugin Author

    Posted 1 year ago #

    I'm not sure this would be possible, because when you modify the excerpt code you can't limit the exceprt words

  5. Sandra
    Member
    Posted 1 year ago #

    For my website i'd like to show to latest news post (one) on the homepage. Those news post are mostly short enough to fit in.
    I've changed line 116 into <div class="rpwe-summary"><?php echo the_content( $length ); ?>
    Maybe i shouldn't have (mis-)used this plugin. But now it works for me. But would be better if i'd known how to limit the content words :-)

    Thank you for your time and your nice plugin.

  6. Satrya
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Sandra,
    I just found this http://wordpress.stackexchange.com/questions/37858/truncate-custom-post-type-content, try to change

    <div class="rpwe-summary"><?php echo the_content( $length ); ?>

    to

    <div class="rpwe-summary"><?php echo apply_filters( 'the_content', wp_trim_words( get_the_content(), 15, '…' ) ); ?>

    Change 15 to fit your needs

  7. Sandra
    Member
    Posted 12 months ago #

    wp_trim_words will also take strip out all the tags

  8. Satrya
    Member
    Plugin Author

    Posted 12 months ago #

    Sorry, for late reply. Hmm.. I'm still searching what function can fit your needs.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.