After reading a bit on regex and preg, starting from a previous example of a similar problem and testing it I was able to answer my own question.
I added this function to functions.php:
<?php
/** Plugin Name: WPSE (#167237) Redirect after comment */
add_filter('comment_post_redirect', 'redirect_after_comment');
function redirect_after_comment($location)
{
return preg_replace("/comment-page-([\d]+)\/#comment-([\d]+)/", "2", $location);
}
It’s replacing the part of the url stating the comment page and comment anchor with “2”. It may not be the cleanest solution but it’s how I managed to do as a beginner.
Related Posts:
- Comment submission & navigation redirects to default language
- Paginate result set from $wpdb->get_results()
- Reverse comment pagination numbers
- Is there any way to override “break comments into pages” and “close comments for old posts” on certain posts, but not on others?
- How to no follow the paginated comments
- Comments Pagination as an unordered list
- How to add pagination to comments?
- Comment pagination – How to show determined number of comments on the first page?
- changing comment-page-# to something like review-page-#
- How do you turn on comments for only the last page of a paginated post?
- Set noindex page-comment from Pages 2, 3 and More?
- Pagination Comments Doesn’t Show
- PAIN. Comments Pagination
- Redirect when click on “response” in comment section
- Incorrect redirection after commenting on custom type
- What is causing wp-comments-post.php to redirect to the browser’s IP address?
- assumed as comment line
- Comment Pagination
- get_query_var(‘paged’) for WP_Comment_Query always return 1 when using paginate_comments_links()
- Re-Direct After Comment Submit IF Comment Comes from Sign-Up Page
- Comments pagination: reverse JUST the links texts (1-2-3 to 3-2-1), not comments order
- What is wrong with this? [closed]
- Comments pagination on author page
- Redirect first time comments
- If paginated comments don’t span to a second page, how do I hide the div wrapper?
- WordPress comment pagination : newest comments on first page
- Pagination comments
- Remove “#comments” from comments pagination url
- How do I comment out a block of tags in XML?
- R: Comment out block of code
- Why do I get comment spam even with Akismet and Captcha?
- What tools are available for managing/writing to WordPress? [closed]
- How to rearrange fields in comment_form()
- setting comments off as default for pages and custom post types?
- Is it possible to pull comments from facebook into your blog?
- How to show a single post on the front page but have normal paging?
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- Non-threaded comment replies with link to original comment
- Approve comment hook?
- Commenting in user profile page?
- How to change “You must be logged in to post a comment.”
- comment_post_ID 0 (cannot remove from dashboard)
- Disable comments on all posts/pages
- How do I delete all comments from a specific old blog post?
- Removing the “Website” Field from Comments and Replies?
- Stop WordPress redirecting comment-page-1 to the post page?
- Importing old Disqus comments into WordPress
- How to add a class to the comment submit button?
- How to wrap submit button of comment form with div
- What is the difference between $paged and $page?
- How to enable comments for pending and draft posts?
- Using WordPress’ WYSIWYG for comments
- Enable Submit Comment Without Page Reload (Using Ajax)?
- What for is the table “wp_commentmeta” exactly?
- Getting Post Comments for post ID using WP_Query() and a Custom Loop?
- Add option to disable comments on a per posts basis?
- Resetting comment count
- When importing – failed to import: Invalid post type feedback
- How to change the email notification recipient (user) for new comments?
- Redirect user to a custom url after submitting the comment
- Change Comment Author Display Name
- Aggregate comments, with pagination
- Would switching to InnoDB from MyISAM improve performance of comments table?
- Custom comment type based on thread level
- How to add internal, revision comments to page updates
- Allow variable amount of comments before pagination
- How to load and show comments with AJAX instead of pagination?
- Linking to Page Showing Only Comments Without Parent Post
- Comment Reply javascript
- How do we remove the H3 tag for the reply-title I.D
- Comments not appearing at all
- comments reply script not working
- How to display comment form error messages in the same page
- 3 moderators to approve comment
- How to deal with small scale comment spam on small commercial sites? [closed]
- What should I do to make generated avatars different for anonymous comments?
- A plugin where users can comment with Facebook or Twitter or OpenID [closed]
- Check If comment author is registered
- Comments screen in backend, how to disable email address of commenter for non admins
- Add comments from the admin panel?
- How can I limit the number of comments per registered user per day?
- One comment per user per post but be able to reply to existing comments
- How to use a custom comments template
- Comment visibility
- What’s the easiest way to close comments on media/attachments?
- Get comments for more than one post
- How can I add comments to a page?
- How to remove comment spam in WordPress
- Post Comments using WP REST API v2 in WordPress
- show number of open comments on custom dashboard
- Show content only if member left a comment
- Add placeholder attribute to comment form fields
- Why do I get accidental comments without (the required) email address?
- How is comment spam received without a comments form?
- Does a reply to a wordpress comment notify the author of the comment?
- What are the current recommended best-practices for comments.php?
- human_time_diff() returns “48 years ago” for all comments
- How do I set up real anonymous posting in bbpress forums? [closed]
- Comment Count for each Comment Author
- Link name in comments to Author page? Comment Author Meta in Comments?