Question

I've added following code for the URL:

<a href='http://facebook.com/share.php?u="<?php urlencode(the_permalink()); ?>"&amp;t="<?php urlencode(the_title()); ?>"' target="_blank"><i class="icon-facebook"></i><?php _e('Facebook', 'domain'); ?></a>

It generates this output:

<a href='http://facebook.com/share.php?u="http://example.com/abc/"&amp;t="Lorem ipsum dolor sit amet"' target="_blank"><i class="icon-facebook"></i>Facebook</a>

But I get error in the validation:

Bad value http://facebook.com/share.php?u="http://example.com/abc/"&t="Lorem ipsum dolor sit amet" for attribute href on element a: Illegal character in query: not a URL code point.

How can I fix this error? Thanks.

Était-ce utile?

La solution

Do not use " in url. Your link element format should be like;

<a href="http://www.domain.com?a=john" target="_blank">User</a>

You can refer here for html link format, and you can use this;

<a href="http://facebook.com/share.php?u=<?php urlencode(the_permalink()); ?>&amp;t=<?php urlencode(the_title()); ?>" target="_blank"><i class="icon-facebook"></i><?php _e('Facebook', 'domain'); ?></a>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top