KimQuiros of Front End
2/15/2017 - 9:23 PM

Estructura para crear una taxonomia

Estructura para crear una taxonomia

/*TAXONOMY COUNTRIES*/
 function countries_taxonomies() {
 	$labels = array(
 		'name'              => _x( 'Countries', 'taxonomy general name', 'twentyseventeen' ),
 		'singular_name'     => _x( 'Country', 'taxonomy singular name', 'twentyseventeen' ),
 		'search_items'      => __( 'Search Countries', 'twentyseventeen' ),
 		'all_items'         => __( 'All Countries', 'twentyseventeen' ),
 		'edit_item'         => __( 'Edit Country', 'twentyseventeen' ),
 		'update_item'       => __( 'Update Country', 'twentyseventeen' ),
 		'add_new_item'      => __( 'Add New Country', 'twentyseventeen' ),
 		'new_item_name'     => __( 'New Country Name', 'twentyseventeen' ),
 		'menu_name'         => __( 'Country', 'twentyseventeen' ),
 	);


 	register_taxonomy(
 		'countries',
 		'country',
 		array(
 			'hierarchical'      => true,
 			'public' => true,
 			'labels'            => $labels,
 			'show_ui'           => true,
 			'show_in_quick_edit' => true,
 			'rewrite'           => array( 'slug' => 'countries' ),
 			'show_admin_column' => true,
 			'update_count_callback' => '_update_post_term_count',
 			'query_var'         => true,
 			'capabilities' => array(
             	'assign_terms' => 'edit_posts',
             	'edit_terms' => 'manage_categories',
                 'delete_terms' => 'edit_categories',
                 'manage_terms' => 'manage_categories'
          	)
 		)
 	);
 }
 add_action( 'init', 'countries_taxonomies');

 //Register 'Products' post type
 function create_countries_posttype() {
     $args = array(
       'labels' => array(
         'name' => __( 'Countries' ),
         'singular_name' => __( 'Country' ),
         'add_new_item' => 'Add New Country'
         ),
       'public' => true,
       'has_archive' => true,
       'rewrite' => array('slug' => 'countries'),
       'supports' => array('title', 'editor','thumbnail', 'custom-fields'),
       'taxonomies' => array('countries'),
       'has_archive' => true,
       'query_var' => true
     );
   register_post_type( 'countries', $args);
 };
 add_action( 'init', 'create_countries_posttype' );