Notifications
Clear all
Topic starter 28/10/2021 6:34 pm
You can use "template_redirect" to handle any redirects before loading any other resources in WordPress. And, in order to do so... use the below pieace of code.
function custom_redirects() { if ( is_page_template( 'template-appointment.php' ) ) { if( empty( $_GET['package'] ) ){ wp_redirect( home_url( '/' ) ); die; } } } add_action( 'template_redirect', 'custom_redirects' ); Or, simply... function custom_redirects() { if ( is_page_template( 'template-appointment.php' ) ) { wp_redirect( home_url( '/' ) ); die; } } add_action( 'template_redirect', 'custom_redirects' );