Advertisement
Guest User

Untitled

a guest
Mar 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. // Custom Post Type
  2. add_action('init', 'post_type_produto');
  3. // Custom Taxonomy
  4. add_action( 'init', 'create_custom_tax_tipo' );
  5.  
  6. function post_type_produto(){
  7.  
  8.   register_post_type('produtos',
  9.     array(
  10.       'labels' => array(
  11.         'name' => _('Produtos'),
  12.         'singular_name' => _('Produto'),
  13.       ),
  14.       'public'  => true,
  15.       'has_archive' => true,
  16.             'show_ui' => true,
  17.       'menu_icon' => 'dashicons-images-alt',
  18.       'supports' => array('title','thumbnail'),
  19.       'menu_position'=> 5,
  20.     )
  21.   );
  22.  
  23. }
  24.  
  25. /* Método para o registro da Custom Taxonomy Tipo de Produto */
  26. function create_custom_tax_tipo(){
  27.     $custom_tax_nome = 'tipo_de_produto';
  28.     $custom_post_type_nome = 'produtos';
  29.     $args = array(
  30.         'label' => __('Tipo de Produto'),
  31.         'hierarchical' => true,
  32.         'rewrite' => array('slug' => 'tipo')
  33.     );
  34.     register_taxonomy( $custom_tax_nome, $custom_post_type_nome, $args );
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement