在wordpress中,如何在评论后重定向回引用页面? [英] In wordpress, how to redirect after a comment back to the referring page?

查看:28
本文介绍了在wordpress中,如何在评论后重定向回引用页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Wordpress 中的不同类型页面(存档、标签、搜索、主页)上启用了评论,并且在用户发表评论后,我希望他们被重定向回他们的引用页面,而不是单个帖子页.有什么想法吗?

I have comments enabled on different types of pages in Wordpress (archive, tag, search, main page), and after a user posts a comment I would like them to be redirected back to their referring page, not to the single post page. Any ideas?

推荐答案

把它放在你的 functions.php 中:

add_filter('comment_post_redirect', 'redirect_after_comment');
function redirect_after_comment($location)
{
return $_SERVER["HTTP_REFERER"];
}

这篇关于在wordpress中,如何在评论后重定向回引用页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆