is_singular()
only accept post_type
, use is_single('2024')
for specific post.
if (is_single(2024)) {
wp_redirect('http://mysitedomain.com/../rugby/');
exit();
}
Update:
Also wp_redirect()
does not work after headers are sent. Please make sure you are redirecting before headers. So you can hook this function on template_redirect
and put this in functions.php
function redirect_custom_page() {
if (is_single('2024')) {
wp_redirect('http://mysitedomain.com/../rugby/');
exit();
}
}
add_action('template_redirect', 'redirect_custom_page');