Forums

Comment Post Redirect (2 posts)

  1. aaffleck
    Member
    Posted 8 months ago #

    Prerequisite: WordPress installed in sub-directory.

    Just in case anyone else is looking to redirect users back to the post they just posted a comment on and have it scroll to the last posted comment from that user without hacking core files:

    Add this to your themes functions.php file.

    add_filter('comment_post_redirect', 'redirect_after_comment');
    function redirect_after_comment($location)
    {
    	global $wpdb;
    	return $_SERVER["HTTP_REFERER"]."#comment-".$wpdb->insert_id;
    }
  2. another13
    Member
    Posted 3 months ago #

    Thanks! :)

Reply

You must log in to post.

About this Topic