rozanchetta

WordPress - CPT e Taxonomia

Oct 10th, 2011
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.07 KB | None | 0 0
  1. <?php
  2.  
  3. // ARQUIVO PARA OS CUSTOM POST TYPES DO TEMA
  4.  
  5. /* CPT DOCUMENTOS */
  6. add_action( 'init', 'register_cpt_documentos' );
  7. function register_cpt_documentos() {
  8. $labels = array(
  9. 'name' => _x( 'Documentos', 'documentos' ),
  10. 'singular_name' => _x( 'Documento', 'documentos' ),
  11. 'add_new' => _x( 'Adicionar Documento', 'documentos' ),
  12. 'add_new_item' => _x( 'Adicionar Novo Documento', 'documentos' ),
  13. 'edit_item' => _x( 'Editar Documento', 'documentos' ),
  14. 'new_item' => _x( 'Novo Documento', 'documentos' ),
  15. 'view_item' => _x( 'Ver Documento', 'documentos' ),
  16. 'search_items' => _x( 'Localizar documentos', 'documentos' ),
  17. 'not_found' => _x( 'Nenhum Documento encontrado', 'documentos' ),
  18. 'not_found_in_trash' => _x( 'Não há documentos na Lixeira', 'documentos' ),
  19. 'parent_item_colon' => _x( 'Pai Documento:', 'documentos' ),
  20. 'menu_name' => _x( 'Documentos de Clientes', 'documentos' ), /* "Documentos de Clientes" será o texto que vai aparecer no menu do painel */
  21. );
  22. $args = array(
  23. 'labels' => $labels,
  24. 'hierarchical' => true,
  25. 'supports' => array( 'title', 'author', 'editor', 'comments' ),
  26. 'taxonomies' => array( 'cliente' ), /* "Cliente" será a taxonomia para o CPT documentos */
  27. 'public' => true,
  28. 'show_ui' => true,
  29. 'show_in_menu' => true,
  30. 'menu_position' => 5,
  31. 'menu_icon' => 'http://seu-site.com.br/wp-content/themes/seu-tema/images/documentos-icone.gif', /* Crie uma imagem de 16x16 px e salve em seu tema */
  32. 'show_in_nav_menus' => true,
  33. 'publicly_queryable' => true,
  34. 'exclude_from_search' => true,
  35. 'has_archive' => true,
  36. 'query_var' => true,
  37. 'can_export' => true,
  38. 'rewrite' => true,
  39. 'capability_type' => 'post'
  40. );
  41. register_post_type( 'documentos', $args );
  42. }
  43.  
  44. //  T A X O N O M I A S
  45. /* TAX:CLIENTE - PARA O CPT DOCUMENTOS */
  46. add_action( 'init', 'register_taxonomy_cliente' );
  47. function register_taxonomy_cliente() {
  48. $labels = array(
  49. 'name' => _x( 'Clientes', 'cliente' ),
  50. 'singular_name' => _x( 'Cliente', 'cliente' ),
  51. 'search_items' => _x( 'Localizar Cliente', 'cliente' ),
  52. 'popular_items' => _x( 'Clientes Populares', 'cliente' ),
  53. 'all_items' => _x( 'Todos os Clientes', 'cliente' ),
  54. 'parent_item' => _x( 'Cliente Pai', 'cliente' ),
  55. 'parent_item_colon' => _x( 'Cliente Pai:', 'cliente' ),
  56. 'edit_item' => _x( 'Editar Cliente', 'cliente' ),
  57. 'update_item' => _x( 'Atualizar Cliente', 'cliente' ),
  58. 'add_new_item' => _x( 'Adicionar Novo Cliente', 'cliente' ),
  59. 'new_item_name' => _x( 'Novo Nome de Cliente', 'cliente' ),
  60. 'separate_items_with_commas' => _x( 'Separe por vírgulas', 'cliente' ),
  61. 'add_or_remove_items' => _x( 'Adicionar ou remover Cliente', 'cliente' ),
  62. 'choose_from_most_used' => _x( 'Escolha entre os mais usados', 'cliente' ),
  63. 'menu_name' => _x( 'Clientes', 'cliente' ),
  64. );
  65. $args = array(
  66. 'labels' => $labels,
  67. 'public' => true,
  68. 'show_in_nav_menus' => true,
  69. 'show_ui' => true,
  70. 'show_tagcloud' => true,
  71. 'hierarchical' => true,
  72. 'rewrite' => true,
  73. 'query_var' => true
  74. );
  75. register_taxonomy( 'cliente', array('documentos'), $args );
  76. }
  77.  
  78. /* este código refere-se ao post http://rozanchetta.wordpress.com/2011/10/10/area-de-clientes-no-wordpress-criando-o-cpt/
  79.  
Advertisement
Add Comment
Please, Sign In to add comment