我有下面的代码:
<a href="<?php echo $tweet_url; ?>" class="twitter-share-button" data-url="=<?php the_permalink(); ?>" data-via="<?php echo of_get_option('ac_twitter_username'); ?>" data-lang="en" data-related="anywhereTheJavascriptAPI" data-count="vertical">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
但没有工作,所以我试图简化版本:
<a href="http://twitter.com/share?url=<?php echo urlencode(wp_get_shortlink()); ?>&counturl=<?php urlencode(the_permalink()); ?>" class="twitter-share-button" data-count="vertical" data-via="<?php echo of_get_option('ac_twitter_username'); ?>">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
而这一次的工作就好了。只要记住,该用户名必须以某种方式集成在你的主题设置,如果没有的话,你可以改变:
<?php echo of_get_option('ac_twitter_username'); ?>
为了您的Twitter用户名。
我希望这有效,我花了一段时间才找到这个更通用的方法。我不完全知道我在做什么,所以如果有人看到这个方法的问题,请让我知道。到目前为止,它工作得很好。
谢谢!
谢谢......这个页面确实有帮助。 – 2013-04-20 22:16:15