WordPress.org

Ready to get started?Download WordPress

Forums

TPG Get Posts
[resolved] Fix links when char limit hits in the middle of a tag. (2 posts)

  1. Sam
    Member
    Posted 1 year ago #

    I run into a certain situation where the 'read more' link breaks.

    What's happening is when the word limit is reached and it's in the middle of a link.

    [tpg_get_posts fields="post_title, post_content" category_name="news" numberposts="4" show_entire="false" show_excerpt="true" shorten_content="w575" show_meta="false" more_link_text="Read More →"]

    So I've got text like this:

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris <a href="test-link-here">nisi ut aliquip ex ea commodo consequat.</a>

    I'll get at the end
    ...laboris Read More
    but the Read More won't be linked. If you inspect the code, you'll see a broken a href tag with the link in it, like this:
    <a href="<a href="test...

    http://wordpress.org/extend/plugins/tpg-get-posts/

  2. cswaim
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, the shorten_content feature is risky as it either counts characters or words (defined by space separation) and trims the content when the limit is reached. It is not aware of html tags. It should only be be used when control over content is very controlled. Using the read-more tag is safer.

    I will update the doc to reflect this restriction.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.