w3c validation problem – Twitter share button pulling content

I have this twitter share button that pulls 100 characters from the content of the post and its URL for the twitter share.

<a class="popup"
    href="http://twitter.com/share?url=<?php
        echo urlencode(get_permalink($post->ID));
    ?>&amp;text=<?php the_content_limit(100, "");?>">
    <img src="http://zitatezumnachdenken.com/wp-content/uploads/2013/04/twittersmall.png" alt="twitter">
</a>

It’s working but I always get the following validation error
Error

Read More

Can someone help me?

Related posts

Leave a Reply

2 comments

  1. You are sending text unencoded. urlencode that just like you do the permalink.

    <a class="popup" href="http://twitter.com/share?url=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;text=<?php echo urlencode(the_content_limit(100, ""));?>"><img src="http://zitatezumnachdenken.com/wp-content/uploads/2013/04/twittersmall.png" alt="twitter"></a>
    

    Although, the_content_limit looks like it probably echos (based on your usage) instead of returning a string, which you will need. So I expect you will have to find that function and alter it or duplicate it or find some other alternative to get a string that you can encode.

  2. Regarding your comment:

    <?php
        $text = strip_tags(get_the_content());
        if (strlen($text) > 100)
            $text = substr($text, 0, 100).'...';
    ?>
    <a class="popup"
        href="http://twitter.com/share?url=<?php
            echo urlencode(get_permalink());
        ?>&amp;text=<?php echo urlencode($text); ?>">
        <img src="http://zitatezumnachdenken.com/wp-content/uploads/2013/04/twittersmall.png"
            alt="twitter" />
    </a>