WordPress 中的单独评论 URL,用于跨网络的 URI 集成
我一直在开发一个评论系统(对 WordPress 进行逆向工程)。就我而言,我希望每条评论都难以被社交网络处理。这意味着他们需要自己的 URL。我构建了一个页面(comment.php
)并将评论的 ID 存储为获取参数。
问题在于社交网络删除了 get 参数,以便它们可以在其中存储自己的数据。
然后我使用页码系统将其构建到 URL 中作为评论 id,然后使用 str_replace 来获取我们想要的评论的 id。 (即example.com/comment/135
)。这有效,但社交网络删除了页码部分。如果数字后面有字母,他们不会删除它们。
因此,我正在寻找一种拥有单独评论页面的方法。我已经制作了一个主题文件并准备好使用,但我只需要一个有效的标准评论 URL。类似 example.com/comment/135-comment/
的内容有自己的页面,可以从 URI 中提取 ID。这怎么能做到呢?
I have been developing a comment system (reverse engineering the WordPress one). In my case I want each comment to be intractable with social networks. This means that they need they're own URL. I built a page (comment.php
) and stored the ID of the comment as a get parameter.
The problem is that the social networks remove the get parameter so that they can store their own data inside it.
I then built it into the URL using the page numbers system as the comment id and then str_replace to get the id of the comment we want. (i.e. example.com/comment/135
). This worked but the social networks removed the page numbers section. They do not remove them if a letter were to sit after the numbers.
Thus I am looking for a way of having individual comment pages. I have a themed file already made and ready to go, but I just need a standard comment URL that works. Something like example.com/comment/135-comment/
with it's own page that can then extract the ID from the URI. How can this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 htaccess 规则将 example.com/comment/135-comment 重写为 example.com/comment/?id=135
但这仅在您有相应的情况下才有效。 url example.com/comment/ 中的评论模板
通用方法是使用类似
example.com/123-post/135-comment/
的内容,同时包含帖子 id 和评论 id。应该适用于大多数主题。
You can use htaccess rule to rewrite example.com/comment/135-comment to example.com/comment/?id=135
But this will work only if you have the resp. comment template in the url example.com/comment/
A generic way is to use something like
example.com/123-post/135-comment/
with both post id and comment id.Should work with most themes.