Redirect specific author posts to another url

if (is_author(‘admin’)){
add_action(‘template_redirect’, ‘wpse_redirect_posts_to_new_page’);
function wpse_redirect_posts_to_new_page() {
// if this is not a single post or not of type post, do nothing
if ( ! is_single() || get_post_type() != ‘post’)
return;

$url = parse_url(get_the_permalink());
$newdomain = ‘https://www.example.com’;
wp_redirect($newdomain . $url[‘path’]);
exit;
}
}

currently, it’s redirecting all users post to new url

Read more here:: Redirect specific author posts to another url

Leave a Reply

Your email address will not be published. Required fields are marked *