Hai provato ad aggiungere l'ID del post alla query?
Ho aggiunto count(r.post_id) as post_num nel tuo select dichiarazione e ha dato i risultati attesi
.
Per rimuovere i duplicati, usa distinct . Vuoi il conteggio rispetto alla tabella dei tag? Prova
COUNT(distinct pt.post_id) AS post_count; oCOUNT(distinct r.post_id) AS post_count