Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #257152

    So I imported a bunch of posts from another blog. It all worked well except for the comment count. It tells me there are zero comments for each post (but when you open the post, there are comments there). I tried the below code to fix it. It sort of worked, but unfortunately, it didn’t correct the comment count in all places — only in some. Is there some other code I can use to correct the comment count? Thanks!

    <?php
    include(‘wp-config.php’);

    $posts = mysql_fetch_row(mysql_query(“SELECT ID FROM wp_posts ORDER BY ID DESC LIMIT 1”));

    function update_comment_count(){
    for($i=1;$i<($posts[0]+1);$i++){
    $comments = mysql_query(“SELECT SQL_CALC_FOUND_ROWS comment_ID FROM wp_comments WHERE comment_post_ID = ‘$i’ AND comment_approved = 1;”);
    mysql_query(“UPDATE wp_posts SET comment_count = ‘”.mysql_num_rows($comments).”‘ WHERE id = ‘$i’;”);
    }
    return true;
    }

    if(update_comment_count()){
    echo “successful”;
    }
    ?>

    #257839

    Hello!

    This is more of a WordPress issue rather than a theme one, unfortunately is out of the support scope we offer, try contacting a specialist.

    Cheers!
    Josue

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.