• For the list of related posts generated, when excerpts are to be shown, whenever there are tags such as strong or em found within excerpt, they could be left unclosed when the excerpt cut off happens. This will cause the rest of the page content after related posts to be bolded or italic depending on which tag is unclosed.

    The solution would be to strip all tags from the excerpt before displaying them or close them properly before the excerpt cut off happens.

    https://www.ads-software.com/extend/plugins/yet-another-related-posts-plugin/

Viewing 7 replies - 1 through 7 (of 7 total)
  • If there are images in the excerpt Bad Things happen because the image tag almost always gets cut part way through.

    Hmm, it must be a general problem with your excerpts… I simply use WP’s own the_excerpt code to display the excerpt. There’s no custom excerpting code. :/

    Thread Starter eyn

    (@eyn)

    You do have code that manipulates the excerpt. If you go to the option panel there’s a field that says “excerpt length”, and I believe the value of that input is what you use in your code to cut the excerpt off, abruptly. You did not take into account of strong, em or other XHTML tags that might be used within excerpt, and cutting off excerpt abruptly based only on the “excerpt length” is going to create problem of unclosed tag.

    And now if you read back my first post you’ll see some of my suggestions of fixing this problem.

    I hope I make myself clear enough this time. Let me know if you still didn’t get why this is indeed a problem. Thanks!

    @eyn – I made a change to the current development version which may fix the excerpts. Please check it out and let me know if that improves the excerpt behavior. (This new feature requires at least WP 2.5.)

    https://downloads.www.ads-software.com/plugin/yet-another-related-posts-plugin.zip

    Does the new version strip image tags? This is irritating, as I INTENDED my excerpts to include images. I had this plugin working beautifully, displaying an image, followed by the excerpt text, and now it doesn’t display the images. ARGH! If there isn’t a way to stop the plugin from stripping tags, I need to dump it for something else. Couldn’t that be an *option*?

    @nicholasjcoleman – I apologize for the inconvenience, but the yarpp_excerpt() method, as was discussed in this thread, was actually a very ad-hoc method that cut off without balancing tags, often resulting in invalid HTML.

    YARPP 3.0.6 uses WordPress’s recommended method for doing this sort of excerpt cutting, the internal wp_html_excerpt() function. This function does indeed use strip_tags() first. If you’d like to customize the way the excerpt is displayed, you can easily do that using the templating features in YARPP 3: https://mitcho.com/blog/projects/yarpp-3-templates/

    Alternatively, you’re welcome to downgrade to 3.0.5. You can find older versions on the www.ads-software.com site.

    Templates! Of course! I’ll dig into that tonight. I should say, thank you for developing such a useful plugin. And such quick response!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Yet Another Related Posts Plugin] Strip tags for excerpt’ is closed to new replies.