Solved: Twitter button suddenly counts 0 after 301 redirect


I know this has been asked a lot of times but I can’t find a solution. The button was working fine until May 22nd, then all buttons count were set to 0 and remain the same until now.

The problem shows at This is a Wordpress site with the Twitter button set without any plugins, it’s coded directly in the php files, either in single.php as index.php.

The code result is this:


The weird thing is that posts later than May 5th count ok, but prev to that date are all wrong.

curl call for that url returns this:

HTTP/1.1 200 OK
Date: Fri, 31 May 2013 08:19:10 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8g PHP/5.2.17
X-Powered-By: PHP/5.2.17
Link: <>; rel=shortlink
Content-Type: text/html; charset=UTF-8

Any help would be appreciated. Thank you.


Anyone can help me with this issue?


Fixed! I wasn’t aware someone on my team changed the urls in WordPress removing www. Seems like Twitter count button doesn’t take care of 301 redirects, so changing the data-counturl parameter in posts previous to the permalink url change seems to be the solution.

Here’s the code I use:

<?php $date = strtotime(get_the_date('Y-m-d i:s')); $date_change_www = strtotime('2013-05-06 10:00'); //In my case the change of the permalink was earlier than this date $url_to_count = get_permalink(get_the_ID()); if($date < $date_change_www) $url_to_count = str_replace('http://', 'http://www.', $url_to_count); ?> Twitt