Redirect when click on "response" in comment section

admin2025-01-07  4

I use a custom template for some of my categories. These categories offer a comment section in which a user can reply to an comment.

The problem is, that the use (after clicking on the reply link) is redirected to the default singele-view template. Can I change the redirect target to my custom post page? Is there any hook or filter?

I had the same problem after submitting the comment, but this could be solved by adding a filter/action 'comment_post_redirect'.

Thanks for your help!

I use a custom template for some of my categories. These categories offer a comment section in which a user can reply to an comment.

The problem is, that the use (after clicking on the reply link) is redirected to the default singele-view template. Can I change the redirect target to my custom post page? Is there any hook or filter?

I had the same problem after submitting the comment, but this could be solved by adding a filter/action 'comment_post_redirect'.

Thanks for your help!

Share Improve this question asked Dec 14, 2015 at 19:02 BrotzkaBrotzka 1254 bronze badges 4
  • So you'd like to be able to reply inline? Is this template a custom page template, or is it a category archive template? Or is it a category specific category archive template? Where can we find your code? – Tom J Nowell Commented Dec 14, 2015 at 19:55
  • It's a custom template. For these categoriesI don't want to use the default single.php. So I created a template file which gets the current post over $_GET parameters (e.g. website.de/forum/?post=123). Unfortunatelly since I updated to the newest WP-version, the reply function in the comments section redirects to the default single.php (which has no comment-section) instead of redirecting to my custom template/URL. All I need, is to change the redirect path. But I don't know how^^ – Brotzka Commented Dec 15, 2015 at 7:14
  • So you're unaware of category.php or it's siblings, or the taxonomy system? This could be implemented using rewrite rule endpoints to load a different template, or custom post types – Tom J Nowell Commented Dec 15, 2015 at 21:33
  • @Brotzka are you still having an issue with this? – Ethan Rævan Commented Aug 23, 2016 at 19:49
Add a comment  | 

1 Answer 1

Reset to default 0

You could create an alternative comments template that is based off of the regular Wordpress template, and create a link in place of the "respond" button that links to your custom post.

Instead of calling

<?php comments_template(); ?>

Just call

<?php comments_template('/custom-comments.php'); ?>

Here's the Wordpress article for reference - https://codex.wordpress.org/Function_Reference/comments_template

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736259794a616.html

最新回复(0)