在Facebook的"like按钮“中,和代码片段都需要指定一个单独的页面URL。like按钮代码片段应该包含在include中,所以显然我想在like按钮代码片段中使用某种类型的变量,这样它就可以自动检测当前页面的URL。Twitter、LinkedIn和GooglePlus按钮都是自动检测的。
这是我的代码。它工作得很好,但是您可以看到在哪里指定了单个页面的URL。有没有可以替代的变量,这样代码片段就可以放到include中?
谢谢。
发布于 2012-05-06 15:19:16
您可以通过使用XFBML/HTML5版本的Like Button并省略href/data-href属性来实现这一点,方法是不将其包含在指示JS-SDK在呈现Like Button时使用当前页面URL的代码中。
发布于 2013-12-05 04:47:29
你可以用iframe来做这件事。
我的代码是:
<iframe src="//www.facebook.com/plugins/like.php?href='. get_permalink( get_the_ID() ) .'&width&layout=button_count&action=like&show_faces=false&share=false&height=21&appId=438288506277662" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px;" allowTransparency="true"></iframe>注意重要的部分:
href='. get_permalink( get_the_ID() ) .'希望能帮上忙!-杰克
https://stackoverflow.com/questions/10467780
复制相似问题