Move existing blog in Blogger to WordPress

Asked By 30 points N/A Posted on -
qa-featured

I am thinking to move my blog from Blogger to WordPress but I don't want to lose any posts or comments or attached links during this transfer. Is there any way this can be achieved? How? Please advice me if doing so is safe and that I will not face any kind of problem.

SHARE
Answered By 0 points N/A #199599

Move existing blog in Blogger to WordPress

qa-featured

It would be better if you backup your Blogger blog, just be on the safer side. Following are the steps which wpuld be helpful in transferring your current blog in Blogger to WordPress:

1.   First register a new domain and hosting.

2.   Install WordPress.

3.   Go to WordPress admin dashboard and click on Tools to select Import.

4.   Under the Import, select Blogger option.

5.   Authorize WordPress to access your current Blogger account.

All the posts and comments will now be avaible on your new WordPress site.

6.   Now, click on Appearance in themes editor and select Editor. This will open .php file. Copy paste the following code in it and do Update File which will save your changes.

<?php

 

function labnol_blogger_query_vars_filter( $vars ) {

  $vars[] = "blogger";

  return $vars;

}

 

add_filter('query_vars', 'labnol_blogger_query_vars_filter');

 

function labnol_blogger_template_redirect() {

  global $wp_query;

  $blogger = $wp_query->query_vars['blogger'];

  if ( isset ( $blogger ) ) {

    wp_redirect( labnol_get_wordpress_url ( $blogger ) , 301 );

    exit;

  }

}

 

add_action( 'template_redirect', 'labnol_blogger_template_redirect' );

 

function labnol_get_wordpress_url($blogger_slug) {

  global $wpdb;

  if ( preg_match('@^(?:https?://)?([^/]+)(.*)@i', $blogger_slug, $matches) ) {

    $q = "SELECT guid FROM $wpdb->posts LEFT JOIN $wpdb->postmeta

          ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)

          WHERE $wpdb->postmeta.meta_key='blogger_permalink'

          AND $wpdb->postmeta.meta_value='$matches[2]'";

    $wp_url = $wpdb->get_var($q);

  }

  return $wp_url ? $wp_url : home_url();

}

 

?>

7.   In your Blogger dashboard, choose templates. Select “Revert to Classic Template”.

8.   Now again copy paste the following code in the Blogger editor:

<html>

 <head>

    <title><$BlogPageTitle$></title>

    <script>

      <MainOrArchivePage>

          window.location.href='http://labnol.org/'

      </MainOrArchivePage>

      <Blogger> <ItemPage>

          window.location.href='http://labnol.org/?q=<$BlogItemPermalinkURL$>'

      </ItemPage> </Blogger>

    </script>

    <MainPage>

      <link rel="canonical" href="http://labnol.org/" />

    </MainPage>

    <Blogger><ItemPage>

      <link rel="canonical" href="http://labnol.org/?blogger=<$BlogItemPermalinkURL$>" />

    </ItemPage></Blogger>

 </head>

 <body>

    <MainOrArchivePage>

        <h1><a href="http://labnol.org"><$BlogTitle$></a></h1>

    </MainOrArchivePage>

    <Blogger><ItemPage>

        <h1>

          <a href="http://labnol.org/?blogger=<$BlogItemPermalinkURL$>">

            <$BlogItemTitle$>

          </a>

        </h1>

        <$BlogItemBody$>

    </ItemPage></Blogger>

 </body>

</html>

After this process, now if you’ll open any page on your Blogger blog, it will get redirected towards the corresponding WordPress page.

Related Questions