【问题标题】:Twitter share issue checking in HTML5 ValidationHTML5 验证中的 Twitter 共享问题检查
【发布时间】:2014-08-20 09:40:16
【问题描述】:

我正在使用 twitter 在 wordpress 中分享我的帖子。它在共享时工作正常,但在检查 HTML5 验证时显示错误“元素 a 上的属性 href:查询组件中的空白。使用 %20 代替空格。”

我的推特分享代码是,

<a href="http://twitter.com/home?status=<?php the_title(); ?> <?php the_permalink(); ?>" target="_blank"><i class="icon-twitter"></i></a>

错误表明使用 %20 代替空格。但是我不知道在上面的共享代码中包含 %20 的位置。

【问题讨论】:

    标签: html wordpress twitter


    【解决方案1】:
    <?php the_title(); ?> <?php the_permalink(); ?>
                         ^ there
    

    但是,the_title(); 不会输出正确编码的文本,所以你应该通过urlencode() 传递它

    应该是这样的:

    <?php urlencode(the_title()); ?>%20<?php the_permalink(); ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-25
      • 2013-04-13
      相关资源
      最近更新 更多