Posted 3 years ago

Get author object outside of loop in wordpress

I’m posting this here b/c I had a good deal of trouble finding the solution to this issue. 

My goal was to put relevant facebook meta tags in the header of a wordpress theme. Most of this was easy using template and blog_info tags.  However, I wanted the image that is displayed when you share a link on facebook to be the author’s gravatar image.  

Here’s the solution i came up with:

// I'm only trying to get the gravatar if this is a single post page
// otherwise i'll just use a generic image w/the site logo
if ( is_single() ) {
	
	// credit for this first part: http://markojakic.net/get-author-object-outside-the-loop-in-wordpress
        $post_temp = get_post($post_id);
	$user_id = $post_temp->post_author;
	
	$authoremail = get_the_author_meta('user_email', $user_id);
	
        // gravatar uses an md5 hash of the email address for the url of the image
        // so I need to md5 the author's email
	$hImage_md5 = md5($authoremail);
		  
	// Construct gravatar URL to retrieve image - ?s=144 is dimension of gravatar I want
	$hImage = "http://www.gravatar.com/avatar/". $hImage_md5. ".jpg?s=144";
}

Then, in the meta tags, I can use this $hImage variable as the path to the image.

Posted 3 years ago
you can upload any picture or plug in an image URL from the web and ask Google to figure out what it is
Posted 3 years ago

SXSW 2011 – Metrics Driven Design

Great article on Data Driven Design - especially on the heels of #omtrsummit…

Posted 3 years ago
Posted 3 years ago

Immaterials Uses a Wand of Lights to Reveal Hidden Wi-Fi Networks | Co.Design

If you like photography and tech. you should watch this. #photography #tech #fb

Posted 3 years ago

Top Videos | Runner's World

Good word from @BartYasso

Posted 3 years ago

Fix BlackBerry “Requested entity too large” error

I’d been getting this error on my Curve 8530 for months and just found out how to fix it courtesy of someone here at work. Putting it out here for all to see.  

Go to “Options”, then “Advanced Options”, then “Browser” and change the “Default Browser Configuration” to “Internet Browser”.

Posted 3 years ago

Fixing IE7 Z-Index Issues with jQuery | Vance Lucas

Fix z-index issues with jQuery. Where was this 2 hours ago? THANK YOU!

Posted 3 years ago

derekwebb:

this is one of the best things i’ve ever seen.

jamesurbaniak:

Dear God, I love this. Turns out we did win the future.

(via Daily What)

Posted 3 years ago

Free Minimal, Swiss Design WordPress Themes (4 Themes) - Smashing Magazine

Some pretty cool minimal wordpress themes for free download today on @smashingmag