• Hey everyone,

    I’m looking for a way to redirect people who comment on a post back to that post rather than to their comment.

    Anybody know what to do? I’ve tried messing around with the bottom few lines of code in wp-comments-post.php but I’m not very experienced in code:

    $location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
    $location = apply_filters('comment_post_redirect', $location, $comment);
    
    wp_redirect($location);
    
    ?>

    Am I in the right direction? Anybody have any suggestions?

    Thanks for your time!

    -Matsim

Viewing 2 replies - 1 through 2 (of 2 total)
  • Apparently there’s a redirect_to function which you can put in your comments-post.php file instead of having to work in a WP core file. A lot of people have reported success with it, but unfortunately it’s not working for me :(. Search for redirect_to and you’ll find plenty of code examples.

    I’m looking for this similar answer. Have either of you found a solution for this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to NOT automatically redirect to comment after submit?’ is closed to new replies.