Title: Sort posts by share count?
Last modified: August 22, 2016

---

# Sort posts by share count?

 *  Resolved [djuradj](https://wordpress.org/support/users/agent001/)
 * (@agent001)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/)
 * Hi, great plugin! I’m glad someone took the time to make something awesome like
   this.
 * Anyways, I’m interested to know is it possible to use this plugin’s share information
   to sort posts by share count – from most shared posts to the least shared ones
   or the other way around :)?
 * Please make me happy and tell me it’s possible 🙂
 * [https://wordpress.org/plugins/mashsharer/](https://wordpress.org/plugins/mashsharer/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Rene Hermenau](https://wordpress.org/support/users/renehermi/)
 * (@renehermi)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5352849)
 * Hi,
 * this is possible i will write an free Add-On for this function later.
 * Regards,
    René
 *  Thread Starter [djuradj](https://wordpress.org/support/users/agent001/)
 * (@agent001)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5352850)
 * Great that it’s possible. Just one question – how later :D?
 * Until you do, can you give a hint on how to do it.
 *  [Rene Hermenau](https://wordpress.org/support/users/renehermi/)
 * (@renehermi)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5352858)
 * You can use something like this in your single.php to return the posts sorted
   by sharecounts:
 * <?php
 * $mostsharedposts= new WP_Query( array( ‘posts_per_page’ => 10, ‘meta_key’ => ‘
   mashsb_shares’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’ ) );
    while ( $mostsharedposts-
   >have_posts() ) : $mostsharedposts->the_post();
 * /* Your loop here e.g.:*/
    the_title();
 * endwhile;
    ?>
 * But you have to first explode() the meta_value and get the last integer as shares
   are stored in post_meta in a format like 1,4,5,12,26 and not as a single number
 *  Thread Starter [djuradj](https://wordpress.org/support/users/agent001/)
 * (@agent001)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5352934)
 * Thats great!
    Thanks for the help!
 * Just one question, is there a possibility to sort them by shares on a certain
   date?
    For example, most shared posts today, most shared posts yesterday etc?
 *  [Rene Hermenau](https://wordpress.org/support/users/renehermi/)
 * (@renehermi)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5352955)
 * Have you been successful with the code snippet i gave you?
 * If you like to share cour code with me i would be able to release a free Add-
   On out of this.
 * >is there a possibility to sort them by shares on a certain date?
 * This is not possible at the moment, but i am already thinking of a way how to
   do this.
 *  Thread Starter [djuradj](https://wordpress.org/support/users/agent001/)
 * (@agent001)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5352978)
 * I haven’t played around, but I might these days, I just never get around to it.
 * If I make something, I’ll send you the code ;).
 *  [Mario C](https://wordpress.org/support/users/mario-c/)
 * (@mario-c)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5353148)
 *  [Mario C](https://wordpress.org/support/users/mario-c/)
 * (@mario-c)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5353149)
 * Hello, tks for your fantastic plugin!
    [https://wordpress.org/plugins/mashsharer/](https://wordpress.org/plugins/mashsharer/)
 * Now, I’m trying to sort posts by share count with a function call.
 * Regarding this sentence,
    `set_query_var('meta_key', 'mashsb_shares');`
 * Due to the format 1,4,5,12,26 it is said i need to explode() to get the last 
   value.
    Unfortunately i don’t know how to proceeed with that. I’ve read several
   articles on web pages but I can’t get it to work. Can anyone please help me?
 *  [Rene Hermenau](https://wordpress.org/support/users/renehermi/)
 * (@renehermi)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5353150)
 * Hello Mario,
 * with the current version, you are able to sort posts by shares. Use the custom
   meta field ‘mashsb_shares’. It now contains only the total share number

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Sort posts by share count?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/mashsharer_33bbee.svg)
 * [MashShare - Social Media Share Buttons, Social Share Icons](https://wordpress.org/plugins/mashsharer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mashsharer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mashsharer/)
 * [Active Topics](https://wordpress.org/support/plugin/mashsharer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mashsharer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mashsharer/reviews/)

 * 9 replies
 * 3 participants
 * Last reply from: [Rene Hermenau](https://wordpress.org/support/users/renehermi/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/sort-posts-by-share-count/#post-5353150)
 * Status: resolved