2013-12-18 26 views
0

我试图以编程方式在页面上的iframe中包含推文按钮。我希望这可以发布特定帖子的wordpress短链接。包括嵌入式(iframe)推文按钮中的wordpress短链接难度

我正在使用PHP插入到我的WordPress数据库中以下HTML iframe代码以包含weet按钮。该代码看起来像这样

'<iframe allowtransparency="true" frameborder="0" scrolling="no" 
src="https://platform.twitter.com/widgets/tweet_button.html 
?count=horizonatal?url=http://www.mywebsite.com?p= ' 
. $post_id . '"></iframe>' 

正如你可以看到我串接$ POST_ID,这是在PHP代码,与WordPress的其余shortlink“http://www.mywebsite.com?p=”。问题似乎是Twitter小部件解释'?'在我的url属性中作为自己的查询 - 而不是针对我的wordpress网站的查询 - 并且发生了什么是我只能得到http://www.mywebsite.com啾啾。

有没有人知道解决这个问题的方法?

回答

0

您需要使用进行urlencode:

'<iframe allowtransparency="true" frameborder="0" scrolling="no" 
src="https://platform.twitter.com/widgets/tweet_button.html 
?count=horizonatal?url='.urlencode('http://www.mywebsite.com?p='.$post_id) 
.'"></iframe>' 

阅读:http://www.php.net/urlencode