Answers for "wordpress redirect to another page programmatically"

PHP
1

wp_redirect to home page

function redirect_to_home() {
  if(!is_admin() && is_page('2')) {
    wp_redirect(home_url());
    exit();
  }
}
add_action('template_redirect', 'redirect_to_home');
Posted by: Guest on October-02-2020
1

In wordpress, how to redirect after a comment back to the referring page?

add_filter('comment_post_redirect', 'redirect_after_comment');
function redirect_after_comment($location)
{
return $_SERVER["HTTP_REFERER"];
}
Posted by: Guest on November-09-2020

Code answers related to "wordpress redirect to another page programmatically"

Browse Popular Code Answers by Language