34
I'm an avid reader of the Apartment Therapy Blog. I live for the before and after posts of chairs found in a yard sale that go from crap to fab in the time it takes to read a blog (well, I know it's not that quick, but it's still neat to see the transformation).
From time to time I'll see a project that makes me think that I might actually be able to do it. I secretly dream of one day having my apartment/condo/bungalow/dream house pictured in a magazine or blog with some sort of title like "OMG How cute is this place?!" Clever, right?
I mean, my mother is an interior decorator. Something should have rubbed off. I'm glad to say that some of it did. When you walk about mine and husband's apartment, you'll see a cute collection of furniture, pics, wall "art" and other things that tell the story of us. I've learned in this move to this new place that turning a vacant apartment into a lived-in home is a process and that mom can no longer buy us everything we want for our apartment. Trust me, I had a fool-proof plan to get my parents to pity purchase a dining table and chairs for us last time they were up here. But alas, the biggest part of my plan involved cooking a huge meal, but the day of that meal was spent riding bikes around DC...and who has the engergy for cooking after that?!
ANYWAYS...
Back to the task at hand. I found a project that I actually think I can pull off. Next week I will try my hand at making this. I'm even going to try and document the process with pictures and clever words for a blog to come.
Wish me luck...and ignore that sound of husband laughing at my enthusiasim.
35
36
37
38
Save your template, and you have successfully implemented redirection on your Blogger blog.
However, you still need to setup redirection on your WordPress site so that users are redirected to the proper posts.
You need to copy and paste the following code in your WordPress theme’s functions.php file or in a site-specific plugin.
If this is your first time adding code to your WordPress site, then you may want to check our beginner’s guide to pasting snippets from the web into WordPress.
01
function blogger_query_vars_filter( $vars ) {
02
$vars[] = "blogger";
03
return $vars;
04
}
05
06
add_filter('query_vars', 'blogger_query_vars_filter');
07
08
function blogger_template_redirect() {
09
global $wp_query;
10
$blogger = $wp_query->query_vars['blogger'];
11
if ( isset ( $blogger ) ) {
12
wp_redirect( get_wordpress_url ( $blogger ) , 301 );
13
exit;
14
}
15
}
16
17
add_action( 'template_redirect', 'blogger_template_redirect' );
18
19
function get_wordpress_url($blogger) {
20
if ( preg_match('@^(?:https?://)?([^/]+)(.*)@i', $blogger, $url_parts) ) {
21
$query = new WP_Query (
22
array ( "meta_key" => "blogger_permalink", "meta_value" => $url_parts[2] ) );
23
if ($query->have_posts()) {
24
$query->the_post();
25
$url = get_permalink();
26
}
27
wp_reset_postdata();
28
}
29
return $url ? $url : home_url();
30
}