pusatdata

KODE CATEGORY dan TAGS INDEPENDENT

Jun 14th, 2018 (edited)
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. KODE CATEGORY INDEPENDENT dan KODE TAGS INDEPENDENT
  2.  
  3. ------------------ custom tags, tidak muncul jika tidak diisi
  4. <?php
  5. // Here we save the "Genre" terms in a variable.
  6. $penulis_terms = get_the_term_list( $post->ID, 'isbn-digital', '', ', ', ' ' );
  7.  
  8. // Here "Penulis" are displayed if not empty.
  9. if( ! empty( $penulis_terms ) ) {
  10. echo '<div class="entry-btn">ISBN DIGITAL</div> ' . $penulis_terms . ' </td></tr>';
  11. }
  12. ?>
  13. -----------------
  14.  
  15.  
  16.  
  17.  
  18. sebelumnya masukkan kode ini di functions.php:
  19. require_once('functions/theme-post-type.php');
  20.  
  21. juga telah dimasukkan dalam theme-post-type.php
  22. require_once('theme-taxonomy.php');
  23.  
  24. masukkan kode berikut dalam file theme-taxonomy.php:
  25.  
  26. <?php
  27.  
  28. add_action( 'init', 'katt_taxonomy', 0 );
  29. function katt_taxonomy() {
  30. $labels = array(
  31. 'name' => _x( 'Kategori Tausiyah', 'taxonomy general name' ),
  32. 'singular_name' => _x( 'Kategori Tausiyah', 'taxonomy singular name' ),
  33. 'search_items' => __( 'Cari Kategori' ),
  34. 'all_items' => __( 'Semua Kategori' ),
  35. 'parent_item' => null,
  36. 'parent_item_colon' => null,
  37. 'edit_item' => __( 'Edit Kategori' ),
  38. 'update_item' => __( 'Update Kategori' ),
  39. 'add_new_item' => __( 'Tambah Baru' ),
  40. 'new_item_name' => __( 'Tambah Kategori Baru' ),
  41. 'menu_name' => __( 'Kategori Tausiyah' ),
  42. );
  43. // Now register the taxonomy
  44. register_taxonomy('kat-tausiyah',array('tausiyah'), array(
  45. 'hierarchical' => true,
  46. 'labels' => $labels,
  47. 'show_ui' => true,
  48. 'show_admin_column' => true,
  49. 'query_var' => true,
  50. ));
  51. }
  52.  
  53.  
  54. add_action( 'init', 'topik_taxonomy', 0 );
  55.  
  56. function topik_taxonomy() {
  57.  
  58. // Labels part for the GUI
  59.  
  60. $labels = array(
  61. 'name' => _x( 'Topik Tausiyah', 'taxonomy general name' ),
  62. 'singular_name' => _x( 'Topik Tausiyah', 'taxonomy singular name' ),
  63. 'search_items' => __( 'Cari Tausiyah' ),
  64. 'popular_items' => __( 'Topik Terpopuler' ),
  65. 'all_items' => __( 'Semua Topik' ),
  66. 'parent_item' => null,
  67. 'parent_item_colon' => null,
  68. 'edit_item' => __( 'Edit Topik' ),
  69. 'update_item' => __( 'Update Topik' ),
  70. 'add_new_item' => __( 'Tambah Topik' ),
  71. 'new_item_name' => __( 'Nama Topik Baru' ),
  72. 'separate_items_with_commas' => __( 'Pisahkan topik dengan koma' ),
  73. 'add_or_remove_items' => __( 'Tambah atau kurangi topik' ),
  74. 'choose_from_most_used' => __( 'Pilih dari topik populer' ),
  75. 'menu_name' => __( 'Topik Tausiyah' ),
  76. );
  77.  
  78. // Now register the non-hierarchical taxonomy like tag
  79.  
  80. register_taxonomy('topik','tausiyah',array(
  81. 'hierarchical' => false,
  82. 'labels' => $labels,
  83. 'show_ui' => true,
  84. 'show_admin_column' => true,
  85. 'update_count_callback' => '_update_post_term_count',
  86. 'query_var' => true,
  87. ));
  88. }
  89.  
  90. ?>
Advertisement
Add Comment
Please, Sign In to add comment