Advertisement
Guest User

Untitled

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