Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

store locally the counts of share for each author WordPress

My site has many authors to contribute their articles. I use sharethis plugin to let users to share the articles. Is any way to store locally the count of shares for each post, and for each author. So users can sort the post with the count of share or sort the author with the count of share.

For example, there are 3 posts --A, B ,C -- and 2 authors --X,Y --on the website. X posted A and B, and Y post C.

A post got : 2 of fb like, 3 of google+
B post got : 1 of fb like , 2 of google+
C post got: 1 of fb like, 1 of google +

1. How do I display the total count of shares on the post (which are A : 5 people share this post, B: 3 people share this post, C : 2 people share this post )
2. How do I display the total count of shares on the author ( which are X : 8 , and Y: 2)
3. How do I filter posts as per count of shares, and filter authors as per count of shares.

Answers (4)

2011-12-25

Arnav Joy answers:

i think custom field can help you in this situation.

2011-12-25

Luis Abarca answers:

For post use custom post meta.

For authors use custom user meta.

You can filter the content or in the single.php add +1 to the post and the author.


ahonshaw comments:

Thanks Luis,

Can you please explain more on the "You can filter the content or in the single.php add +1 to the post and the author" ? I don't know how to store the count of share to a custom field of author profile. Also if the authors posted more than 2 posts, how do I store the sum of count of shares for all his/her posts?

Thank you!


Luis Abarca comments:

Its something like this, so you only count visits when the user is reading a post entry or page


add_filter('the_content', 'add_visit');

function add_visit( $content )
{
global $post;

if (!is_single() && !is_page() ) {
return $content;
}

// Old value
$current_visits = get_post_meta($post->ID, '_visits', true);

update_post_meta($post->ID, '_visits', $current_visits + 1);

// author ID
$user_id = $post->post_author;

$total = get_user_meta($user_id, '_totalvisits', true);

update_user_meta($user_id, '_totalvisits', $total + 1);

return $content;
}


ahonshaw comments:

Thanks Luis, but what I would like to know is how to store locally the counts of "shares".

For example, there are 3 posts --A, B ,C -- and 2 authors --X,Y --on the website. X posted A and B, and Y post C.

A post got : 2 of fb like, 3 of google+
B post got : 1 of fb like , 2 of google+
C post got: 1 of fb like, 1 of google +

1. How do I display the total count of shares on the post (which are A : 5 people share this post, B: 3 people share this post, C : 2 people share this post )
2. How do I display the total count of shares on the author ( which are X : 8 , and Y: 2)
3. How do I filter posts as per count of shares, and filter authors as per count of shares.

Thank you!

2011-12-25

Hardeep Singh answers:

Requirement has been understood and people provided the solution with custom fields.

Does this answer the question? Or you are looking for implementation on top of "share this" sharing script?

If latter is expected than let me know, I can get both done on your site please reach me at contact details provided in my profile.

Thanks,
Hardeep


ahonshaw comments:

Thanks Hardeep, yes I am looking for the implementation of sharing script. It does not necessary on top of "sharethis" as long as there is better solution to store the count of shares ( facebook, google+,...etc) for each post and for each author.

I will contact you soon if you can help.

Thank you!


Hardeep Singh comments:

Hello,

I am fine to work on this.
Let's get on Skype to discuss and close.

Thanks
Hardeep

2011-12-28

ej_emman answers:

Hello ahonshow,


Regarding with you question on how to count the number of people who share the certain post, in facebook and in google.

I think this could not be solve by wordpress codes, this can be done through scapping using php scripts,. the script will get the number of people who shares in facebook and in google then sum up those and will be recorded to you database.

I am available to work for this one and can be done in less than two(2) hours.

Thanks,


ej_emman


ahonshaw comments:

Hi ej_emma, can it be used on top of "share this" plugin ? How do I reach you?

Thanks!


ej_emman comments:

hello ahonshow,

I just send you pm.

cheers,


ej_emman