简体   繁体   English

同一Facebook上的多个页面上的按钮一样?

[英]Same Facebook like button over multiple pages?

What is considered the best method for 'like' buttons (same for twitter and google+) so that multiple pages use the same one? 什么是“喜欢”按钮(对Twitter和google +相同)的最佳方法,以便多个页面使用相同的按钮?

If i have an article spanned over several pages, it's giving each page a unique like button and i want it to be the same one. 如果我有一篇文章跨越几页,它给每页一个唯一的喜欢按钮,我希望它是相同的。 I'd also like to try an automated solution if you know of one. 如果您知道一个自动解决方案,我也想尝试。

Using wordpress, I'm currently thinking of using a custom field to input the url directly, but that's not as automated as I'd like. 使用wordpress,我目前正在考虑使用自定义字段直接输入网址,但这并没有我想要的自动化。 What is the solution? 解决办法是什么?

Currently thinking this might be the easiest: 当前认为这可能是最简单的:

<?php
//Attempt to get page one of a reviews url for social bar on extra review pages.
$socialfield=get_post_meta($post->ID, 'social_url', true);
//if isset & not blank else use the_permalink()
$socialfield=(isset($socialfield) && $socialfield!='')?$socialfield:the_permalink();

where 'social_url' is the custom field. 其中“ social_url”是自定义字段。

then do this: 然后这样做:

<div class="fb-like" data-href="<?=$socialfield?>" data-send="false" data-width="450" data-show-faces="true"></div>

I just wish for a more automated method or at the very least confirmation that this is probably the best way to go. 我只希望有一种更自动化的方法,或者至少可以肯定这是最好的方法。

when you get the like button you will get the codes something like this in HTML5 Tab 当您点击“ like按钮时,您将在“ HTML5”标签中获得类似这样的代码

<div class="fb-like" data-href="http://www.example.com" data-send="false" data-width="450" data-show-faces="true"></div>

Just note the data-href="http://www.example.com" attribute, 只要注意data-href="http://www.example.com"属性,
now what to do, just get the parameter from the url something like http://www.example.com/post/first-post/ and set this value in data-href attribute. 现在该怎么办,只需从url中获取参数即可,例如http://www.example.com/post/first-post/然后在data-href属性中设置此值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM