Guest User

Untitled

a guest
Jun 15th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.85 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Adicionamos uma acção no inicio do carregamento do WordPress
  5.  * através da função add_action( 'init' )
  6.  */
  7. add_action( 'init', 'create_post_type_film' );
  8.  
  9. /**
  10.  * Esta é a função que é chamada pelo add_action()
  11.  */
  12. function create_post_type_film() {
  13.  
  14.     /**
  15.      * Labels customizados para o tipo de post
  16.      *
  17.      */
  18.     $labels = array(
  19.         'name' => _x('Films', 'post type general name'),
  20.         'singular_name' => _x('Film', 'post type singular name'),
  21.         'add_new' => _x('Add New', 'film'),
  22.         'add_new_item' => __('Add New Film'),
  23.         'edit_item' => __('Edit Film'),
  24.         'new_item' => __('New Film'),
  25.         'all_items' => __('All Films'),
  26.         'view_item' => __('View Film'),
  27.         'search_items' => __('Search Films'),
  28.         'not_found' =>  __('No Films found'),
  29.         'not_found_in_trash' => __('No Films found in Trash'),
  30.         'parent_item_colon' => '',
  31.         'menu_name' => 'Films'
  32.     );
  33.  
  34.     /**
  35.      * Registamos o tipo de post film através desta função
  36.      * passando-lhe os labels e parâmetros de controlo.
  37.      */
  38.     register_post_type( 'film', array(
  39.         'labels' => $labels,
  40.         'public' => true,
  41.         'publicly_queryable' => true,
  42.         'show_ui' => true,
  43.         'show_in_menu' => true,
  44.         'has_archive' => 'films',
  45.         'rewrite' => array(
  46.          'slug' => 'films',
  47.          'with_front' => false,
  48.         ),
  49.         'capability_type' => 'post',
  50.         'has_archive' => true,
  51.         'hierarchical' => false,
  52.         'menu_position' => null,
  53.         'supports' => array('title','editor','author','thumbnail','excerpt','comments')
  54.         )
  55.     );
  56.  
  57.     /**
  58.      * Registamos a categoria de filmes para o tipo de post film
  59.      */
  60.     register_taxonomy( 'film_category', array( 'film' ), array(
  61.         'hierarchical' => true,
  62.         'label' => __( 'Film Category' ),
  63.         'labels' => array( // Labels customizadas
  64.         'name' => _x( 'Categories', 'taxonomy general name' ),
  65.         'singular_name' => _x( 'Category', 'taxonomy singular name' ),
  66.         'search_items' =>  __( 'Search Categories' ),
  67.         'all_items' => __( 'All Categories' ),
  68.         'parent_item' => __( 'Parent Category' ),
  69.         'parent_item_colon' => __( 'Parent Category:' ),
  70.         'edit_item' => __( 'Edit Category' ),
  71.         'update_item' => __( 'Update Category' ),
  72.         'add_new_item' => __( 'Add New Category' ),
  73.         'new_item_name' => __( 'New Category Name' ),
  74.         'menu_name' => __( 'Category' ),
  75.     ),
  76.         'show_ui' => true,
  77.         'show_in_tag_cloud' => true,
  78.         'query_var' => true,
  79.         'rewrite' => array(
  80.             'slug' => 'films/categories',
  81.             'with_front' => false,
  82.         ),
  83.         )
  84.     );
  85.  
  86.     /**
  87.      * Esta função associa tipos de categorias com tipos de posts.
  88.      * Aqui associamos as tags ao tipo de post film.
  89.      */
  90.     register_taxonomy_for_object_type( 'tags', 'film' );
  91.  
  92. }
  93. ?>
Advertisement
Add Comment
Please, Sign In to add comment