Friday, November 27, 2020
Home Blogging How to Fix Category and Comment Count After WordPress Import

How to Fix Category and Comment Count After WordPress Import

Are you noticing an incorrect remark depend after the WordPress import? Importing a WordPress web site utilizing the built-in importer can generally mess up your WordPress feedback depend. Whereas all of the feedback are safely imported and visual within the admin space, your posts will present an incorrect remark depend in your web site. This similar import error also can affect class depend and customized taxonomy depend. On this article, we’ll present you how you can repair class and feedback depend after importing WordPress.

As you observed within the screenshot above, after the import our remark depend and class depend is exhibiting zero as an alternative of the particular quantity. Let’s check out how you can repair it.

First you must create a whole WordPress backup of your web site. You need to do that each time you’ll carry out a serious change in your web site. We suggest utilizing BackupBuddy, it’s the most complete WordPress backup plugin in the marketplace.

After getting made the backup, let’s transfer on to the subsequent step.

Open a plain textual content editor like Notepad and easily copy and paste the next code:

if (!mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)) {  die('Could not connect: ' . mysql_error());  }
if (!mysql_select_db(DB_NAME)) {  die('Could not connect: ' . mysql_error());  }
$result = mysql_query("SELECT term_taxonomy_id FROM ".$table_prefix."term_taxonomy");
while ($row = mysql_fetch_array($result)) {
  $term_taxonomy_id = $row['term_taxonomy_id'];
  echo "term_taxonomy_id: ".$term_taxonomy_id." count = ";
  $countresult = mysql_query("SELECT count(*) FROM ".$table_prefix."term_relationships WHERE term_taxonomy_id = '$term_taxonomy_id'");
  $countarray = mysql_fetch_array($countresult);
  $count = $countarray[0];
  echo $count."<br />";
 mysql_query("UPDATE ".$table_prefix."term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term_taxonomy_id'");
$result = mysql_query("SELECT ID FROM ".$table_prefix."posts");
while ($row = mysql_fetch_array($result)) {
  $post_id = $row['ID'];
  echo "post_id: ".$post_id." count = ";
  $countresult = mysql_query("SELECT count(*) FROM ".$table_prefix."comments WHERE comment_post_ID = '$post_id' AND comment_approved = 1");
  $countarray = mysql_fetch_array($countresult);
  $count = $countarray[0];
  echo $count."<br />";
  mysql_query("UPDATE ".$table_prefix."posts SET comment_count = '$count' WHERE ID = '$post_id'");

That you must exchange DB_HOST, DB_USER, DB_PASSWORD along with your WordPress database host (normally localhost), database username, and password.

Yow will discover all this data by logging into your WordPress internet hosting cPanel or by taking a look at your wp-config.php file utilizing a file supervisor.

After getting changed the knowledge, save this file as comments-fix.php in your desktop.

Now you’ll need to add this file to your web site’s root listing. You are able to do that by utilizing an FTP consumer or by utilizing the file supervisor in your webhosting management panel.

After importing the file to your web site, you must open your net browser and go to this file:

Exchange along with your web site’s deal with.

Visiting this file in your browser will run the script which merely loops by means of your posts, class, tags, feedback, and so on and replace the depend.

You May Also Like : How to Add Email Subscription to Your WordPress Blog

Necessary: When you’re carried out fixing your WordPress remark depend, you must delete comments-fix.php file out of your server.

That’s all, we hope this text helped you replace feedback depend after importing WordPress. You might also wish to take a look at our information on the most typical WordPress errors and how you can repair them.

If you liked this article, make sure to hit the bell for getting our latest updates and share this article with your friends in every social media platforms.


Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Post Matric & Pre-Matric Scholarship Scheme – How to Apply

Scholarship is an effective way to finance your training. If your child is vivid and anticipated to have a promising profession forward then you...

How to Earn Money from Google Online Jobs

  I can swear… Google on-line jobs comes on the highest of my listing for real on-line jobs. I've been getting cash from Google from the final...

List of Different MBA Courses in India

Master of Business Administration, generally known as MBA, is one of probably the most coveted and prestigious academic {qualifications} in India. Earlier, most MBA...

Everything You Should Know About Salary Slip / Pay Slip

Salary slip, also referred to as pay slip, is given to each worker of corporations small and enormous. Some employers challenge the pay slip...

Recent Comments