Technical SEO

My like and dislike counter always shows 0

Grabzies Ecommerce · 23 September 2026 · 3 replies
I've got a simple thumbs up / thumbs down vote on my homepage. Votes are definitely saving, as I can see the rows in the database, but the counter on the page always shows 0 likes and 0 dislikes.

The API returns counts from a database function and the page reads counts.like and counts.dislike. No errors in the console. Any ideas?
3 Replies
John Carlsson · 23 Sept 2026
Check the exact property names the database function returns. A very common cause of a counter stuck at 0 is a singular/plural mismatch: the function returns { likes: 2, dislikes: 0 } but the code reads counts.like and counts.dislike. Those don't exist, so they come back undefined, and undefined || 0 displays as 0 with no error at all.

Log the raw object the API returns and compare the keys character by character with what the page reads.
Grabzies Ecommerce · 23 Sept 2026
That was exactly it. The function returns likes and dislikes, and I was reading like and dislike in four places. Fixed and it shows the real count now.
John Carlsson · 23 Sept 2026
Worth checking one more thing while you're in there: how you stop the same person voting twice. If you fingerprint voters by IP and your app sits behind a proxy, make sure you're using the real client IP, not a header the client can change, and not the proxy's own 127.0.0.1. Otherwise every visitor looks like the same person, or anyone can vote as many times as they like.

Join the discussion

Sign in to reply, share your SEO experience and connect with other members.