You can store the counts as key and link a value and sort them before display like this :
$sort_tab = array();
while (have_posts()) : the_post();
if ( has_post_thumbnail() ) {
the_post_thumbnail( array(40,40) );
}
$url = get_the_permalink();
$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' );
$json_data = json_decode($json, false);
$sort_tab[$json_data->data[0]->total_count] = $url;
endwhile;
sort($sort_tab);
foreach($sort_tab as $count=>$link)
{
echo $link.' has '.$count.' votes';
}
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- Get post ids from WP_Query?
- Nested meta_query with multiple relation keys
- Some doubts about how the main query and the custom query works in this custom theme?
- How to query for most viewed posts and show top 5
- WP_Query vs get_posts
- Using OR conditions in meta_query for query_posts argument
- Order posts by ID in the given order
- Query Multiple Post types each with own meta query
- Get posts by menu ID
- Get the number of posts from the current page results
- WordPress Custom Query to show posts from last x years
- How to know which one is the main query?
- Perform query with meta_value date
- Meta Query with date and time on the same Day before given time
- get_the_title($postID) OR get_the_title()?
- How do I create my own nested meta_query using posts_where / posts_join?
- Best practice for multiple queries on page
- How to find out what “Blog pages show at most” is set to [duplicate]
- Multiple search queries on one page
- Retrieve or Query Pages by ID
- How do you query wordpress posts using a math formula between multiple meta field values?
- How add a custom posttype name using ACF field to a query post array
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Page navigation doesn’t show when query category
- Multiple instances of Featured Image Query
- 2 loops on page – one with orderby rand second orderby date
- How do you Query posts with nothing in common?
- Custom category search box for WordPress
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- Query with a meta value inside a given range
- Store sticky post’s ids in a transient
- Five posts from a category in footer
- How to build a WP_Query using mulitple tags and using AND or OR operator between them
- Multiple loops without repeating content
- How to display multiple custom fields with the same meta_key in an ascending order?
- Bypass “supress_filters” in WP Query
- Some doubts about how the main query and the custom query works in this custom theme?
- How to display an other custom post type in a different custom post type’s archive?
- Display custom tags on pages that have a specific page parent
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- How to increase load time of an archive/search page (WP_Query)
- How to query for all posts that have a particular meta key?
- Exclude All Posts Which Do Not Have A Tag Assigned
- How can I override one post and make it display content for another post?
- Get all posts which was posted on X Days WordPress
- Easy way to write complex queries in wordpress
- Filter post query to only show direct children of category
- get_posts output always same post
- Query_posts works when appending via AJAX call wp_query doesn’t?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- complex get_posts() query to select child pages
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- Posts query according to meta box date
- How do I add a relation parameter to my filter query?
- Get next/prev image/attachment in time with date query
- Max Posts and Memory Limit
- specific post is not excluded from the loop
- Why doesn’t my WP Meta Query return any results?
- Paginate pages with dynamic query
- filter posts by meta key with pagination
- Trouble Making WP_Query paged
- Determine if ID is page or post and query the ID
- How to query for a page, get data, then query for child pages of that page
- Optimising WP_Query with ACF Fields
- Query post and sort by custom value calculated with custom field on cpt
- Filter products on category AND tag
- Query post ordered by meta value that show first post that contained a tag
- pre_user_query vs pre_get_posts
- How do I stop the same post showing multiple times in a archive?
- Get posts that match defined arrays of tags
- trying to change from query_post to WP_Query
- Problem with my loops
- How to query most recent post for each author?
- I need query_posts() to order results first by a meta value and then by post ID
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- My entry results are not consistently alphabetized
- Orderby query does not work for custom fields even with meta query
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- query_posts() doesn’t seem to be called in my page
- Modify query to exclude certain ids and certain parents and its corresponding children
- Some doubts about how the main query and the custom query works in this custom theme?
- Fetching $_POST from Page Template into functions.php
- How to order by datediff in WP loop?
- Ordering Posts by parent category, name ascending
- Optimising specific Query with ACF meta objects
- How to organize a WP_Query’s list of posts by category and display category title?
- query_posts with sorting on a custom datestamp
- Query Posts by date range with fixed beginning and end
- Multiple loop for “featured” items returns wrong posts
- Having trouble using this post category query on multiple pages?
- Exclude categories and subcategories in QueryLoop
- query_posts problem – need help
- Incorrect posts displayed on category page
- WP Query – Show custom posts only if user contain some user meta
- Show number of posts AND number on current page (cannot make it work)
- new WP_Query with order args – no more distinction between categories