Pooja Kshatriya Pooja Kshatriya - 1 year ago 76
PHP Question

How to redirect page in Wordpress by coding

I am using WordPress twentysixteen theme. There I have created a page template. In that I have created a login form. I want to redirect a user to the next page after successful login.

I tried:

header('Location: http://website.com/my-page/');
wp_redirect(get_page_by_title('My Page'));

saying error

headers already sent

Answer Source

You can workarond this problem by redirecting page via javascript

echo '<script type="text/javascript">window.location = "/my-page/"</script>';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download