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
- Is it possible to pull comments from facebook into your blog?
- What is the difference between $paged and $page?
- Enable Submit Comment Without Page Reload (Using Ajax)?
- Getting Post Comments for post ID using WP_Query() and a Custom Loop?
- How to deal with small scale comment spam on small commercial sites? [closed]
- How to use a custom comments template
- Comment visibility
- Allowing more elements in comments via functions.php
- Set post comments open function
- “Categories” for comments?
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- Allow guests comments on single post
- Delayed commenting
- An action hook where a comment meta is updated
- Display number of comment replies
- Last comment page first with full number of comments?
- Only subscriber role user can comment not other
- Strategies for coping with hyperagressive spambots?
- Relaxing unescaped HTML filtering inside tags?
- How to save new comment as custom comment type?
- How to remove the “on” string before recent comments link?
- WordPress comments email notification for authors
- How to get the result of comments_number() as a string instead of printing it out?
- Should I still worry about paginated comments with the latest wordpress versions?
- How to dont allow registered users to comment without being logged in?
- How can I edit the Twenty Ten Theme to remove the comments box when a page uses a specific template?
- Highlight Author Comments issues
- wp_insert_comment and security
- How can someone submit a comment when my site has no comment field?
- Show comments in a popup
- Archive comment w/o moving to spam/trash
- Get the top level comment ID
- Custom WP Comments Query with Nested Comments Possible? (Hierarchy/Depth)
- Editing WordPress comments : generating comment from selection
- How can I assign a specific id to the last comment of a post
- Modify WordPress Comment From For AMP Html
- delete duplicate comments
- code highiglight not working comment
- Comment number does not increment
- Cancel comment filter?
- get_comments not working consistantly with post_id
- How to edit the text below “Leave a Reply”
- Safe to remove this: when using a 3rd Party Comment App? [closed]
- Commenting system for WordPress
- How to create post comment from different domain
- get_comment_link without pagination base in the returned URL?
- Comments on future posts
- Copy and Paste Password for Comments
- Display custom text when comments are closed
- paginate_comments_links() not working
- I need to disable Disqus comments pre-approval, but i can’t find where
- Remove Javascript generated by Comments
- How to Trigger comment_form_after action if comment_form() not used
- Need Comment Link Help
- Page comes up blank using w3 total cache [closed]
- Comment Table Size Results in Slow Page Loads and 500 Errors
- Changing the Comment Fields using Filter (without success)
- Custom sort comments with select form
- Subcriber getting multiiple notifications for new comments
- Limit Comment Line Count – Add Read More Button
- Commenter username copies author username
- How can I enable commenting from mobile view?
- Displaying comment rating stars in carousel
- Enable comments option
- Change Comment Text [duplicate]
- How to force users to nest their comments
- Insert comment and still use moderation
- Auto approve all comments (editor)
- Pagination is not working, how to trace it properly?
- add field comment [duplicate]
- Let users comment on categories in WordPress
- Customize comment notification e-mails with HTML