Advertisement
Guest User

WP_Query

a guest
Apr 27th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?php
  2.  
  3. $query = new WP_Query(array('posts_per_page'=>-1));
  4.  
  5. $sort_tab = array();
  6. while ($query->have_posts()) : $query->the_post();
  7.  
  8. if ( has_post_thumbnail() ) {
  9. the_post_thumbnail( array(40,40) );
  10. }
  11.  
  12. $url = get_the_permalink();
  13. $json = file_get_contents( 'https://graph.facebook.com/fql?q=SELECT%20like_count,%20total_count,%20share_count,%20click_count,%20comment_count%20FROM%20link_stat%20WHERE%20url%20=%20%27' . $url . '%27' );
  14. $json_data = json_decode($json, false);
  15. $sort_tab[$json_data->data[0]->total_count] = $url;
  16.  
  17. endwhile;
  18. wp_reset_query();
  19. sort($sort_tab);
  20.  
  21. foreach($sort_tab as $count=>$link)
  22. {
  23.     echo $link.' has '.$count.' votes <br>';
  24. }
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement