Skip to content

Instantly share code, notes, and snippets.

View clutchwave's full-sized avatar

Mike Roberto clutchwave

View GitHub Profile
clutchwave / discourse-reply-count.php
Last active November 8, 2017 21:46
WordPress Discourse Reply Count Update Script
// This script will look at ALL of your WordPress blog posts (post type 'post' in this case)
// and look at the reported number of comments in the post's meta / custom_field, 'pp_discourse_replies'
// It will then look at all associated Discourse Topics (as per the WP-Discourse plugin's discourse_topic_id)
// custom field and and check the actual number of replies. If they are different, it will update the custom field.
// You can then override your WP theme's comment count PHP to display this meta field (pp_discourse_replies)
// and run this script on cron, so you have regularly-updated comment counts, but are not slowing your site down
// retrieving them.