Skip to content

Instantly share code, notes, and snippets.

View Osz's full-sized avatar

Aziz Osz

View GitHub Profile
@stresslimit
stresslimit / gist:943745
Created April 27, 2011 05:09
WP order posts by number of facebook likes
<?php
// get fb likes from fb graph api
// put this block in single.php, or somewhere you have $post and have setup postdata [inside a Loop]
$obj = json_decode( file_get_contents( 'http://graph.facebook.com/?id='.get_permalink() ) );
$likes = $obj->shares;
update_post_meta($post->ID, '_fb_likes', $likes, false);
// make a Loop [in a template page or whatever] to query and display posts ordered by fb like popularity
$args = array(