【问题标题】:wordpress tags as twitter sharer URL hastagswordpress 标签作为 twitter 共享 URL 主题标签
【发布时间】:2014-05-26 15:26:49
【问题描述】:

我想在 Twitter 上分享一篇 wordpress 帖子。我正在使用这个:

     <a href="https://twitter.com/share?url=<?php the_permalink() ?>&text=<?php the_title() ?>&via=<?php the_author() ?>&hashtags=<?php the_tags('', '') ?>" ></a>

我的问题是the_tags() 打印了&lt;a&gt; 标签内的标签! 我知道主题标签应该在 URL 上用逗号分隔。 那么我怎样才能使用the_tags('', '')(它用逗号分隔标签作为标签需要)作为twitter标签?

我很欣赏没有插件的解决方案 谢谢

【问题讨论】:

    标签: wordpress twitter tags


    【解决方案1】:

    你可以使用:get_the_tags() 代替 the_tags()

    http://codex.wordpress.org/Function_Reference/get_the_tags

         $posttags = get_the_tags();
         $twitter_tags="";
         if ($posttags) {
          foreach($posttags as $tag) {
              $twitter_tags.=$tag->name.',';
          }
         }
    
         echo $twitter_tags; // inside twitter link
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-08
      • 1970-01-01
      • 2015-11-29
      • 2012-01-20
      • 1970-01-01
      • 2014-11-09
      • 2022-11-05
      • 1970-01-01
      相关资源
      最近更新 更多