This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 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. |