我为网址添加了以下代码:
<a href='http://facebook.com/share.php?u="<?php urlencode(the_permalink()); ?>"&t="<?php urlencode(the_title()); ?>"' target="_blank"><i class="icon-facebook"></i><?php _e('Facebook', 'domain'); ?></a>
它会生成此输出:
<a href='http://facebook.com/share.php?u="http://example.com/abc/"&t="Lorem ipsum dolor sit amet"' target="_blank"><i class="icon-facebook"></i>Facebook</a>
但我在验证中遇到错误:
价值不佳 http://facebook.com/share.php?u= “http://example.com/abc/” &amp; T公司=“的Lorem ipsum dolor sit amet“for element href on element a:非法 查询中的字符:不是URL代码点。
如何修复此错误? 感谢。
答案 0 :(得分:0)
请勿在网址中使用"
。您的链接元素格式应该是;
<a href="http://www.domain.com?a=john" target="_blank">User</a>
您可以参考here获取HTML链接格式,您可以使用此功能;
<a href="http://facebook.com/share.php?u=<?php urlencode(the_permalink()); ?>&t=<?php urlencode(the_title()); ?>" target="_blank"><i class="icon-facebook"></i><?php _e('Facebook', 'domain'); ?></a>