php-wordpressHow to redirect to another page in WordPress using PHP?
Redirecting to another page in WordPress using PHP is a simple process. The following example code block will redirect the user to a page with the URL http://example.com/new-page
:
wp_redirect( 'http://example.com/new-page' );
exit;
The code consists of two parts:
wp_redirect()
: This function redirects the user to the specified URL.exit;
: This statement terminates the script execution.
For more information, please refer to the WordPress Codex.
More of Php Wordpress
- How to disable PHP warnings in WordPress?
- How to get the current URL in WordPress using PHP?
- How to check the PHP version in WordPress?
- How to increase the upload limit in WordPress using PHP?
- How to create a snippet in WordPress using PHP?
- How to use the WordPress REST API with PHP?
- How to run an SQL query in WordPress using PHP?
- How to create pagination in WordPress using PHP?
- How to check if a user is logged in in WordPress using PHP?
See more codes...