下面的代码将访问者重定向到您想要的任何页面。
// Redirect to thank you post after comment
add_action('comment_post_redirect', 'redirect_to_thank_page');
function redirect_to_thank_page() {
return 'https://example.com/thank-you';
}但是,我使用特性,网络中的所有子网站都使用相同的活动主题。因此,我是否可以根据他们所访问的站点重定向访问者?
也就是说,如果您在example.com/fr上留下评论,那么您将被自动重定向到example.com/fr/谢谢页面。
如果在上面的片段中使用blog-id或子目录名称,可能会有帮助吗?
WP Multisite方法:子目录
致以问候。
发布于 2020-01-25 00:35:10
如果您在所有网站上都有一个带有相同片段的感谢页面,您可以这样做:
add_action('comment_post_redirect', 'redirect_to_thank_page');
function redirect_to_thank_page() {
return get_bloginfo('url').'/thank-you-page';
}get_bloginfo('url')检测您当前所在的子站点
https://wordpress.stackexchange.com/questions/357085
复制相似问题