Monday, May 16, 2016

Redirect to custom page after comment in WordPress

In WordPress when a user comments on an Article, post or page he is redirected to the same page after commenting.

But in some scenarios it is required that user should be redirected to some other URL after commenting. This can be done with a simple piece of code.

Open your active theme's functions.php file and add the following line at the end of the line.

function wp_comment_redirect_url($location) {    
        return "http://www.yourdomain.com";
    }

add_filter('comment_post_redirect', 'wp_comment_redirect_url');


Now user will be redirected to the URL to have set.

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...