Support » Plugin: TPG Get Posts » Fix links when char limit hits in the middle of a tag.

  • Resolved Sam

    (@samsamuelcousinscom)


    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/

Viewing 1 replies (of 1 total)
  • Plugin Author cswaim

    (@cswaim)

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Fix links when char limit hits in the middle of a tag.’ is closed to new replies.