Advertisement
pusatdata

WP: Manually Creating Custom Taxonomies - Category

Oct 7th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Manually Creating Custom Taxonomies
  2.  
  3.  
  4. ===========================
  5.  
  6. //hook into the init action and call create_book_taxonomies when it fires
  7. add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );
  8.  
  9. //create a custom taxonomy name it topics for your posts
  10.  
  11. function create_topics_hierarchical_taxonomy() {
  12.  
  13. // Add new taxonomy, make it hierarchical like categories
  14. //first do the translations part for GUI
  15.  
  16. $labels = array(
  17. 'name' => _x( 'Penerbit', 'taxonomy general name' ),
  18. 'singular_name' => _x( 'Penerbit', 'taxonomy singular name' ),
  19. 'search_items' => __( 'Search Penerbit' ),
  20. 'all_items' => __( 'All Penerbit' ),
  21. 'parent_item' => __( 'Parent Penerbit' ),
  22. 'parent_item_colon' => __( 'Parent Penerbit:' ),
  23. 'edit_item' => __( 'Edit Penerbit' ),
  24. 'update_item' => __( 'Update Penerbit' ),
  25. 'add_new_item' => __( 'Add New Penerbit' ),
  26. 'new_item_name' => __( 'New Penerbit Name' ),
  27. 'menu_name' => __( 'Penerbit' ),
  28. );
  29.  
  30. // Now register the taxonomy
  31.  
  32. register_taxonomy('penerbit',array('post'), array(
  33. 'hierarchical' => true,
  34. 'labels' => $labels,
  35. 'show_ui' => true,
  36. 'show_admin_column' => true,
  37. 'query_var' => true,
  38. 'rewrite' => array( 'slug' => 'penerbit' ),
  39. ));
  40.  
  41. }
  42.  
  43. Kode menampilkan di web, masukkan ke single.php:
  44. <?php the_terms( $post->ID, 'penerbit', 'Penerbit: ', ', ', ' ' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement