相同的Facebook像多个页面上的按钮?

问题描述:

什么被认为是喜欢按钮的最佳方法(对于twitter和google +是相同的),以便多个页面使用相同的按钮?

What is considered the best method for 'like' buttons (same for twitter and google+) so that multiple pages use the same one?

如果我的文章跨越了几页,它给每个页面一个独特的按钮,我希望它是一样的。我也想尝试一个自动化解决方案,如果你知道一个。

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.

使用wordpress,我正在考虑使用自定义字段来直接输入url,但这不像我想要的那样自动化。什么是解决方案?

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. 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();

其中'social_url'是自定义字段。

where 'social_url' is the custom field.

然后这样做:

<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.

当您获得 喜欢按钮,您将在HTML5标签中获得类似的代码

when you get the like button you will get the codes something like this in HTML5 Tab

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

只需注意 data-href =http://www.example .com属性,

现在该怎么做,只需从url中获取参数,例如 http://www.example.com/post / first-post / 并将此值设置为 data-href 属性。

Just note the data-href="http://www.example.com" attribute,
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.