I would like to have commenters going to the page 2 of a paginated post. My posts are separated by the <!--more--> tag so i have the www.site.com/post-title and www.site.com/post-title/2/. I want users to visit the second part of the post after commenting.

I found other questions explaining how to move the user to the paginated comment, that is www.site.com/post-title/comment-page-x/#comment-x but not to other pages of a paginated post.

Edit: My site has the common setting for permalink that is wpinstallation/%postname%/. When paginated, it becomes /%postname%/2/ for page 2.


  • This is a Regex what you are showing. Do you know how that works? Also: please edit your question and add exactly how your paginated permalinks and how default permalinks (page 1/n) look like.
    – kaiser
    Commented Nov 3, 2014 at 2:30
  • hi @kaiser Thanks for the reply, I have no idea how Regex work, I just found it on another forum as solution to another problem. I added the information of my permalinks structure, it is exactly as I mentioned on the post.
    – lu-bhz
    Commented Nov 4, 2014 at 21:36
  • You can't just take some code from somewhere and repost/own it. Please add a link to the source and to the license. Thanks.
    – kaiser
    Commented Nov 4, 2014 at 21:38
  • You don't have to remove the code. Just add a link to the source and state the license :)
    – kaiser
    Commented Nov 5, 2014 at 2:46
  • @kaiser it was posted originally here wordpress.org/support/topic/… I couldn't find a specific license for the official Wordpress forum, but I presume would be the same as the whole Wordpress, and as it is stated at the bottom of that page, GPLv2
    – lu-bhz
    Commented Nov 7, 2014 at 21:34

1 Answer 1


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:

/** 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.