如何像 WordPress 博客页面一样为每个 facebook 设置图像、描述和标题?
可能的重复:
Facebook Sharer 如何选择图像?
所以我想设置一个不同的当用户在博客主页上点击某篇文章的“赞”时,每篇文章的图像、标题和描述。这与 Mashable 和 Techcrunch 的做法相同。到目前为止,我只能找到包括在头部添加元标记的解决方案。但问题是主页有很多帖子,每个帖子都有不同的标题、图片等。那么我该怎么做,有人有任何想法吗?
Possible Duplicate:
How does Facebook Sharer select Images?
So I wanted to set a different image, title and description to each post when a user clicks like on that certain post on the main blog page. This is the same way that Mashable and Techcrunch have it. So far I've only been able to find solution that include adding a meta tag on the head section. But the problem is the home page has many posts and each post has a different title, image, etc. So do I do this, anyone has any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜你必须为每个手动设置类似的东西。
http://developers.facebook.com/docs/reference/javascript/FB。 ui/
并且对于每个项目执行类似
Jquery
Now 的操作,这个 jQuery 是不正确的(我很确定),并且您还需要拥有 Facebook 应用程序和所有设置。但我认为这种事情会运作得很好。
或者找到一个插件,例如 addthis.com 或 facebook“like”插件,如果您插入永久链接,则可能会起作用。
http://developers.facebook.com/docs/reference/plugins/like/
I'm guessing you'd have to manually set up something like this for each.
http://developers.facebook.com/docs/reference/javascript/FB.ui/
And for each item do something like
Jquery
Now, this jQuery isn't right (i'm pretty sure), and you'll need to have the Facebook app and all that set up as well. But I'm thinking something of this sort would work pretty well.
Or find a plugin, like addthis.com or the facebook "like" plugin might work if you insert the permalink.
http://developers.facebook.com/docs/reference/plugins/like/
您可以编写一个函数,获取帖子图片、标题和描述,并将其动态插入到该部分中:
它:
...为了获取描述,我刚刚在我的帖子中添加了一个“自定义字段”,并在此处使用此函数读取 在这里定义标题、图像和描述是更好的方法,但我认为这可以让你知道如何做到这一点。至少我对这样的方式很满意。
PS:为了澄清这一点,根据您的需要更改变量并将其放入模板的functions.php 文件中,仅此而已。一旦有人点击您希望已插入博客中的“赞”按钮,标题、图像和描述就会出现在他/她的 Facebook 墙上!
You can write a function that takes the posts picture, title and description and dynamically inserts that into the Section:
...to get the description I just added a 'custom field' in my posts and read it with this function here:
There may be better ways to define the title, image and description in here, but that gives you an idea how to do it I think. At least I'm quite happy with that way.
PS: Just to clarify, change the variables to your needs and put this in your functions.php file of your template and that's pretty much it. As soon as someone clicks the like button you hopefully inserted already in your blog, the title, image and description will appear on his/her facebook wall!