Jumlah Post Di Taxonomy Kosong

zen

Administrator
Staff member
#1
Jadi kasusnya seperti ini, postingan sebenernya udah dimasukin taxonomy, contoh saja taxonomy genre yang berisi action, adventure, horror. Nah, ketika agan cek di area taxonomy genre ternyata jumlah post di taxonomy action dan lainnya masih 0 "nol" padahal dipostingan sudah dimasukin taxonomy tersebut. Bingung? lihat gambar di bawah:

count-750x410.jpg

Sudah paham sekarang? nah kalo agan memiliki masalah seperti ini cara benerinnya silakan buat file fix.php di direktori utama web agan, seperti ini

fix.jpg

masukan script ini ke dalam file fix.php yang agan buat tadi

PHP:
<?php
include("wp-config.php");

$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD)) {  die('Could not connect: ' . mysqli_error());  }
if (!mysqli_select_db($conn,DB_NAME)) {  die('Could not connect: ' . mysqli_error());  }

$result = mysqli_query($conn, "SELECT term_taxonomy_id FROM ".$table_prefix."term_taxonomy");
while ($row = mysqli_fetch_array($result)) {
  $term_taxonomy_id = $row['term_taxonomy_id'];
  echo "term_taxonomy_id: ".$term_taxonomy_id." count = ";
  $countresult = mysqli_query($conn, "SELECT count(*) FROM ".$table_prefix."term_relationships WHERE term_taxonomy_id = '$term_taxonomy_id'");
  $countarray = mysqli_fetch_array($countresult);
  $count = $countarray[0];
  echo $count."
";
mysqli_query($conn, "UPDATE ".$table_prefix."term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term_taxonomy_id'");
        }

$result = mysqli_query($conn, "SELECT ID FROM ".$table_prefix."posts");
while ($row = mysqli_fetch_array($result)) {
  $post_id = $row['ID'];
  echo "post_id: ".$post_id." count = ";
  $countresult = mysqli_query($conn, "SELECT count(*) FROM ".$table_prefix."comments WHERE comment_post_ID = '$post_id' AND comment_approved = 1");
  $countarray = mysqli_fetch_array($countresult);
  $count = $countarray[0];
  echo $count."
";
  mysqli_query("UPDATE ".$table_prefix."posts SET comment_count = '$count' WHERE ID = '$post_id'");
        }
?>
Lalu jalankan scriptnya (http://domain-agan.com/fix.php), jika proses fixing sudah selesai, silakan cek kembali taxonomy agan.

Semoga beruntung :D

(sumber: webdesign101.net)