Support » Plugin: WordPress Related Posts » post excerpt appends "…" even when not truncated

  • Hello,

    I noticed that when Display Post Excerpt is checked, even for excerpts shorter than the max # of characters, the plugin still adds “…” at the end. This looked a little funny on my site because my post excerpts already end in …, so they ended up looking something like this “This post talks about blah blah blah……”

    Pretty simple fix – I just changed this code in wp_related_posts.php:

    if ($options["display_excerpt"]){
    				$excerpt_max_length = $options["excerpt_max_length"];
    				if($related_post->post_excerpt){
    					$output .= '<br /><small>' . (mb_substr(strip_shortcodes(strip_tags($related_post->post_excerpt)), 0, $excerpt_max_length)) . '...</small>';
    				} else {
    					$output .= '<br /><small>' . (mb_substr(strip_shortcodes(strip_tags($related_post->post_content)), 0, $excerpt_max_length)) . '...</small>';
    				}
    			}

    To this:

    if ($options["display_excerpt"]){
    				$excerpt_max_length = $options["excerpt_max_length"];
    				if ($related_post->post_excerpt) {
                                         $output .= '<br /><small>';
                                         if (strlen(strip_shortcodes(strip_tags($related_post->post_excerpt))) > $excerpt_max_length) {
    					 $output .= (mb_substr(strip_shortcodes(strip_tags($related_post->post_excerpt)), 0, $excerpt_max_length)) . '...</small>';
                                            } else { $output .= strip_shortcodes(strip_tags($related_post->post_excerpt)) . '</small>'; }
    				} else {
    					$output .= '<br /><small>' . (mb_substr(strip_shortcodes(strip_tags($related_post->post_content)), 0, $excerpt_max_length)) . '...</small>';
    				}
    			}

    Just wanted to suggest maybe adding this to the next release, unless the intention was to always append “…” to the excerpt regardless of whether it was actually truncated or not.

    Great plugin – thanks for all of your work!
    – Scott

    http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/

  • The topic ‘post excerpt appends "…" even when not truncated’ is closed to new replies.