update mysql using yum
February 16, 2015install ruby
March 6, 20151. login to your blogger account, go to Template section and enable classic template from the bottom of the page.
2. edit your main template (click edit html) and place the following code between the head elements
<script>
<MainOrArchivePage>
window.location.href="http://jewelryloveaffair.com/"
</MainOrArchivePage>
<Blogger><ItemPage>
str = "<$BlogItemPermalinkURL$>";
window.location.href='http://jewelryloveaffair.com/?blogger='+str.replace(/^(?:\/\/|[^\/]+)*\//, "");
</ItemPage></Blogger>
</script>
<MainPage>
<link rel="canonical" href="http://jewelryloveaffair.com/" />
</MainPage>
<Blogger>
<ItemPage>
<link rel="canonical" href="http://jewelryloveaffair.com/?blogger=<$BlogItemPermalinkURL$>" />
</ItemPage>
</Blogger>
3. in your wordpress template’s functions.php place the following code:
function add_query_vars_filter( $vars ){
$vars[] = "blogger";
return $vars;
}
add_filter( 'query_vars', 'add_query_vars_filter' );
function blogger_template_redirect() {
global $wp_query;
$blogger = get_query_var('blogger');
if ( !empty( $blogger ) ) {
wp_redirect( get_wordpress_url ( $blogger ) , 301 );
exit;
}
}
add_action( 'template_redirect', 'blogger_template_redirect' );
/* finds slug by string in order to cover the case when blogger cuts the urls because they were too big! */
function get_wordpress_url($blogger) {
$the_slug= $blogger;
$temp = explode('/', $the_slug);
$the_slug= str_replace('.html', '', $temp[2]);
global $wpdb;
$query = "
SELECT *
FROM $wpdb->posts
WHERE $wpdb->posts.post_name LIKE '%".$wpdb->esc_like($the_slug)."%' LIMIT 1";
$result = $wpdb->get_results($query);
if(!empty($result)) {
$url = get_permalink($result[0]->ID);
return $url ? $url : home_url();
}
}