SHARE
TWEET

Jumlah post in category

pustakakoran Mar 20th, 2017 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Paste kode berikut di function.php:
  2. ==================================
  3.  
  4. /*
  5. ---------------------
  6. Count Post in Category
  7. ---------------------
  8. */
  9. function wt_get_category_count($input = '') {
  10.     global $wpdb;
  11.     if($input == '')
  12.     {
  13.         $category = get_the_category();
  14.         return $category[0]->category_count;
  15.     }
  16.     elseif(is_numeric($input))
  17.     {
  18.         $SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->term_taxonomy.term_id=$input";
  19.         return $wpdb->get_var($SQL);
  20.     }
  21.     else
  22.     {
  23.         $SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->terms.slug='$input'";
  24.         return $wpdb->get_var($SQL);
  25.     }
  26. }
  27.  
  28.  
  29. ===============================================
  30. Untuk menampilkannya, gunakan kode berikut:
  31. <?php echo wt_get_category_count(); ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top