Hi,
this is possible i will write an free Add-On for this function later.
Regards,
René
Great that it’s possible. Just one question – how later :D?
Until you do, can you give a hint on how to do it.
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
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?
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.
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 ;).
Hello, tks for your fantastic plugin!
https://ww.wp.xz.cn/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?
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