让 Facebook 像指向博客文章网址一样?

发布于 2024-12-28 05:44:37 字数 182 浏览 3 评论 0原文

我正在向我的 WordPress 页面添加类似 facebook 的按钮。在 single.php 上,对于每篇博客文章 - 效果都很好。但我还想在索引页面上的帖子中添加类似 facebook 的按钮。我可以这样做,但检索到的 url 是主索引页面,这是有道理的。有没有一种方法可以在我的博客主页上有多个“喜欢”按钮,并且仍然使每个按钮都指向该帖子?

I´m adding facebook like buttons to my wordpress-page. On single.php, for each blog post - which works fine. But I would also like to add facebook like button to the posts on the index page. I could do that, but the url retrieved is the main index page, which makes sense. Is there a way I can have multiple like buttons on my blog main page, and still make each one of them to point to the post?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风情万种。 2025-01-04 05:44:37

是的,您可以将每个点赞按钮的 href 参数设置为帖子永久链接。这是 HTML 版本中的 data-href 属性:

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

Yes, you set the href parameter for each individual like button to the post permalink. It's the data-href attribute in the HTML version:

<div class="fb-like" data-href="http://example.com/your-blog-post" data-send="true" data-width="450" data-show-faces="true"></div>
岁吢 2025-01-04 05:44:37

那么,在索引页和“The Loop”内部,您可以使用 the_permalink() 用作“赞”按钮 href

Well, in the index page and inside "The Loop", you could use the the_permalink() function as your Like button href.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文