Advertisement
salvatorifabio

custom post & taxonomy

Dec 18th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. add_action( 'init', 'create_prodotti' );
  2.  
  3. function create_prodotti() {
  4. $args = array(
  5. 'labels' => post_type_labels( 'Prodotti' ),
  6. 'public' => true,
  7. 'publicly_queryable' => true,
  8. 'show_ui' => true,
  9. 'show_in_menu' => true,
  10. 'query_var' => true,
  11. 'rewrite' => true,
  12. 'capability_type' => 'post',
  13. 'has_archive' => true,
  14. 'hierarchical' => false,
  15. 'menu_position' => null,
  16. 'taxonomy' => array (''),
  17. 'supports' => array('title',
  18. 'editor',
  19. 'author',
  20. 'thumbnail',
  21. 'excerpt',
  22. 'comments',
  23. 'custom-fields' // pannello custom fields
  24. )
  25. );
  26.  
  27. register_post_type( 'prodotti', $args );
  28. }
  29.  
  30. function post_type_labels($name) {
  31.  
  32. return array(
  33. 'name' => _x( $name, 'post type general name' ),
  34. 'singular_name' => _x( 'Prodotto', 'post type singular name' ),
  35. 'add_new' => __( 'Aggiungi nuovo' ),
  36. 'add_new_item' => __( 'Aggiungi nuovo prodotto'),
  37. 'edit_item' => __( 'Modifica prodotto'),
  38. 'new_item' => __( 'Nuovo prodotto' ),
  39. 'view_item' => __( 'Vedi prodotto' ),
  40. 'search_items' => __( 'Cerca'. $name ),
  41. 'not_found' => __( 'Nessun prodotto trovato'),
  42. 'not_found_in_trash' => __( 'Non ci sono ' . $name . ' prodotti nel Cestino' ),
  43. 'parent_item_colon' => ''
  44. );
  45. }
  46.  
  47. function add_custom_taxonomies() {
  48. // Add new "Locations" taxonomy to Posts
  49. register_taxonomy('marchio', 'prodotti', array(
  50. // Hierarchical taxonomy (like categories)
  51. 'hierarchical' => true,
  52. // This array of options controls the labels displayed in the WordPress Admin UI
  53. 'labels' => array(
  54. 'name' => 'Marchi',
  55. 'singular_name' => 'Marchio',
  56. 'search_items' => 'Cerca Marchio',
  57. 'all_items' => 'Tutti i Marchi' ,
  58. 'parent_item' => 'Parent Marchio',
  59. 'parent_item_colon' => 'Parent Marchio:',
  60. 'edit_item' => 'Edit Marchio',
  61. 'update_item' => 'Update Marchio' ,
  62. 'add_new_item' => 'Nuovo Marchio' ,
  63. 'new_item_name' => 'New Marchio Name',
  64. 'menu_name' => 'Marchi',
  65. ),
  66. // Control the slugs used for this taxonomy
  67. 'rewrite' => array(
  68. 'slug' => 'marchio', // This controls the base slug that will display before each term
  69. 'with_front' => false, // Don't display the category base before "/locations/"
  70. 'hierarchical' => true,// This will allow URL's like "/locations/boston/cambridge/"
  71. 'query_var' => true,
  72. ),
  73. ));
  74. }
  75. add_action( 'init', 'add_custom_taxonomies', 0 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement