Searched through google but can't find anything related to it. Either I don't know what terms to use when searching or there's nothing about it.

I want to remove #comment-* we all know that it appears after some1 is submitting a comment.

So any thoughts on that one?

I used a hook to redirect from the page where the comment was first submitted

add_filter('comment_post_redirect', 'redirect_after_comment');
function redirect_after_comment($location)
  return $_SERVER["HTTP_REFERER"];

Maybe will help someone in near future.

  • 4
    Please do not put your solution into the question. Write a real answer instead, and mark the question as answered then. – fuxia Apr 28 '13 at 15:30

The asker solved the issue with $_SERVER["HTTP_REFERER"] but refused to post that as a real solution.

Let me suggest something better, because the referer might be empty or full of malicious code. Never use that.

First, we make sure, we get both arguments for that hook:

add_filter( 'comment_post_redirect', 'wpse_97580_comment_redirect', 10, 2 );

Then we use the post ID of the comment to generate a safe URL for redirection:

function wpse_97580_comment_redirect( $location, $comment )
    return get_permalink( $comment->comment_post_ID );

In my opinion, this is bad for usability: the user might have to search her comment now on a long page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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