Advertisement

Getting facebook fan counts to work with Momizat multinews

 (Read 1587 times)

Admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1549
    • The Jucktion
As you might have encountered on our home page, that our facebook count for the facebook page is displayed wrong. and the theme developers are nowhere to be seen. I hoped to see some updates to not delve into the code to fix it which might break in an update. But with no updates for a long time I decided to check the issue myself.

image

After checking the error log and the code, I found that the theme is using an old declaration to get the fan counts for facebook.

You will have to edit the file:
Code: [Select]
themes/multinews/framework/functions/social-counters.php
Find/Replace
Code: [Select]
$data = wp_remote_get('https://graph.facebook.com/' . $page_id .'?fields=likes,link&access_token='.$facebook_access_token);
with

Code: [Select]
$data = wp_remote_get('https://graph.facebook.com/' . $page_id .'?fields=fan_count,link&access_token='.$facebook_access_token);
and
Code: [Select]
        $count = isset($json['likes']) ? intval($json['likes']) : 0;
with
Code: [Select]
        $count = isset($json['fan_count']) ? intval($json['fan_count']) : 0;

The likes are stored temporarily on transient options which you will have to clear after you finish editing the files. I use WPSweep to get those cleaned and it worked perfectly.

Other counters may still have errors, I may check if anyone has issues.

I hope this helps someone

Advertisement

Best Affiliate Program