You’ll have to modify your old theme’s function.php
. Add the following code:
function redirect_posts() {
global $post;
if ($post->post_type=='post') {
return header('location:http://newblog.com/posts/'.$post->post_name);
}
}
add_action('wp', 'redirect_posts');
The if
codintion will check if the page what’s currently viewed is a post and it returns a header redirect to the new blog based on the old blog post’s slug.