Reply To: Help needed: Migrating from Blogger to WordPress

In

Home Forums Technical Support Help needed: Migrating from Blogger to WordPress Reply To: Help needed: Migrating from Blogger to WordPress

#45437
Ankit Puri
Participant

Peter
You can use wordpress import feature to import all your blogspot posts to wordpress then all you need to do is set 301 perma redirection and change your permalinks to match with blogspot.

The permalink structure will be like this /%year%/%monthnum%/%postname%.html

This are the codes you need to add on your blogspot blog template for 301 perma redirection

after <blogger> add

<MainOrArchivePage>
<script language=”javascript”><!–
var blog_root=http://www.shoutmeloud.com/;
document.location.href=blog_root;
//–></script>
</MainOrArchivePage>

<ItemPage>
<script language=”javascript”><!–
var process_page=”http://www.shoutmeloud.com/bloggerposts.php”;
var newpage=process_page;
var oldlink=”<$BlogItemPermalinkUrl$>”;

newpage+=”?p=”+oldlink;
newpage=newpage.toLowerCase();
document.location.href=newpage;
//–></script>
</ItemPage>

and after <head> add

<meta http-equiv=”refresh” content=”0;url=http://www.yourdomain.com/” />

Now create a bloggerposts.php on the root of your wordpress directory and add this code it, replace yourdomain with your blog name

<?php

require($_SERVER[‘DOCUMENT_ROOT’].’/wp-blog-header.php’);
$search_link = $_GET[‘p’];
$vars = explode(‘/’, $search_link);
$num = count($vars) – 1;
$filename = $vars[$num];
$slug = str_replace(“.html”, “”, $filename);

$SQL = “SELECT posts.* FROM $wpdb->posts AS posts WHERE posts.post_name = ‘$slug’ LIMIT 1”;
$posts = $wpdb->get_results(“$SQL”);

if ($posts) {
foreach ($posts as $post) {
$found_link = get_permalink($post->ID);
}
}
else
{
$found_link = “http://www.shoutmeloud.com/&#8221;;
}

?>

<html>
<head>
<title>Redirecting…</title>
<script language=”javascript”><!–
document.location.href=”<?php echo ($found_link); ?>”;
//–></script>

<meta http-equiv=”refresh” content=”2;url=<?php echo ($found_link); ?>”>

</head>
<body>
<h1>Redirecting…</h1>
<p>You can also proceed immediately to “><?php echo ($found_link); ?>.</p>
<p>The main blog URL is http://www.yourdomain.com/.</p>
</body>
</html>

I hope this will help you.