如何根据传递给页面的变量使facebook like按钮具体化

如何根据传递给页面的变量使facebook like按钮具体化

问题描述:

i am working on a website that is big into php databases i'm trying to get it so there is a (facebook)like button for every post that is made for the site. the only problem is the facebook likes are not individualized and are page specific so when i like 1 they all get liked. this would not be a problem if i could put each one in the comment section of the post since it is on a different page but each comment section is individualized by a php id variable that i pass to it (which does not actually change the url but only what shows up on the page). is there any way that i could make it so that each like button behaves on its own? here is the site i have been working on.

www.linkerbolt.com

我正在开发一个对PHP数据库很重要的网站我试图得到它所以有一个( facebook)像为网站制作的每个帖子的按钮。 唯一的问题是Facebook喜欢的不是个性化的,而且是特定于页面的,所以当我喜欢1时,他们都会受到欢迎。 如果我可以将每个人放在帖子的评论部分,因为它位于不同的页面,但每个评论部分都是由我传递给它的php id变量个性化(这实际上不会更改网址),这不会是一个问题 但只有页面上显示的内容)。 是否有任何方法可以使每个像按钮一样独立行动?\我所在的网站是什么。 p>

www.linkerbolt.com p> div>

In the div that you've created which contains the facebook like button, you can add a data-href property, and in this property you can add a link to whichever page you want :

data-href="www.whicheverpageyouwant.com"

In your case, you would need a different URL for each post. You can create a page that receives a post id and displays a single post (www.yoursite/posts/35) and set the data-href to point to each corresponding page when you have to display several on the same page.

Ficticious example :

<?php foreach ($forumPosts as $post) : ?>

    <div class="fb-like" 
        data-href="wwww.yoursite/forumpost/<?php echo $post['id'];?>" 
        data-send="true" 
        data-width="450" 
        data-show-faces="true" />

<?php endforeach; ?>