Created
May 30, 2014 14:55
-
-
Save AndreaBarghigiani/ce8a2c2b9dbf6f6ab47b to your computer and use it in GitHub Desktop.
Con questo codice creo un CPT e ci collego una tassionomia. La pagina archivio per quest'ultima prende il nome di taxonomy-cat_saliscale.php ma non viene letta correttamente...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Carrelli CPT | |
Plugin URI: http://mariocarrelli.com | |
Description: Il CPT per contenere i carrelli e struttura categorie personalizzata | |
Version: 1.0 | |
Author: Andrea Barghigiani | |
Author URI: http://andreabarghigiani.info | |
License: GPL2 (o anche 3 va bene) | |
*/ | |
// Register Custom Post Type | |
function mario_carrelli() { | |
$labels = array( | |
'name' => _x( 'Saliscale', 'Post Type General Name', 'text_domain' ), | |
'singular_name' => _x( 'Saliscala', 'Post Type Singular Name', 'text_domain' ), | |
'menu_name' => __( 'Saliscale', 'text_domain' ), | |
'parent_item_colon' => __( 'Carrelli Generali:', 'text_domain' ), | |
'all_items' => __( 'Tutti Carrelli', 'text_domain' ), | |
'view_item' => __( 'Visualizza Carrelli', 'text_domain' ), | |
'add_new_item' => __( 'Aggiungi Carrello', 'text_domain' ), | |
'add_new' => __( 'Aggiungi Nuovo', 'text_domain' ), | |
'edit_item' => __( 'Modifica', 'text_domain' ), | |
'update_item' => __( 'Aggiorna', 'text_domain' ), | |
'search_items' => __( 'Cerca', 'text_domain' ), | |
'not_found' => __( 'Non Trovato', 'text_domain' ), | |
'not_found_in_trash' => __( 'Non lo Trovo nel Cestino', 'text_domain' ), | |
); | |
$rewrite = array( | |
'slug' => 'saliscale', | |
'with_front' => true, | |
'pages' => true, | |
'feeds' => true, | |
); | |
$args = array( | |
'label' => __( 'm_carrelli', 'text_domain' ), | |
'description' => __( 'Questa e\' la lista dei saliscale.', 'text_domain' ), | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'thumbnail' ), | |
'taxonomies' => array( 'cat_saliscale' ), | |
'hierarchical' => false, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_nav_menus' => true, | |
'show_in_admin_bar' => true, | |
'menu_position' => 5, | |
'menu_icon' => 'dashicons-cart', | |
'can_export' => true, | |
'has_archive' => true, | |
'exclude_from_search' => false, | |
'publicly_queryable' => true, | |
'rewrite' => $rewrite, | |
'capability_type' => 'page', | |
); | |
register_post_type( 'm_carrelli', $args ); | |
} | |
// Hook into the 'init' action | |
add_action( 'init', 'mario_carrelli', 0 ); | |
// Register Custom Taxonomy | |
function car_taxonomy() { | |
$labels = array( | |
'name' => _x( 'Categorie Saliscale', 'Taxonomy General Name', 'text_domain' ), | |
'singular_name' => _x( 'Categoria Saliscale', 'Taxonomy Singular Name', 'text_domain' ), | |
'menu_name' => __( 'Cat Saliscale', 'text_domain' ), | |
'all_items' => __( 'Tutte Categorie', 'text_domain' ), | |
'parent_item' => __( 'Pricipale', 'text_domain' ), | |
'parent_item_colon' => __( 'Carrelli Generali:', 'text_domain' ), | |
'new_item_name' => __( 'Nuova Cat Saliscale', 'text_domain' ), | |
'add_new_item' => __( 'Aggiungi Nuovo', 'text_domain' ), | |
'edit_item' => __( 'Modifica', 'text_domain' ), | |
'update_item' => __( 'Aggiorna', 'text_domain' ), | |
'separate_items_with_commas' => __( 'Separa con virgola', 'text_domain' ), | |
'search_items' => __( 'Cerca', 'text_domain' ), | |
'add_or_remove_items' => __( 'Aggiungi o Rimuovi', 'text_domain' ), | |
'choose_from_most_used' => __( 'Seleziona dai piu\' Usati', 'text_domain' ), | |
'not_found' => __( 'Non Trovato', 'text_domain' ), | |
); | |
$rewrite = array( | |
'slug' => 'saliscale', | |
'with_front' => true, | |
'hierarchical' => true, | |
); | |
$args = array( | |
'labels' => $labels, | |
'hierarchical' => true, | |
'has_archive' => true, | |
'public' => true, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'show_in_nav_menus' => true, | |
'show_tagcloud' => true, | |
'rewrite' => $rewrite, | |
); | |
register_taxonomy( 'cat_saliscale', array( 'm_carrelli' ), $args ); | |
} | |
// Hook into the 'init' action | |
add_action( 'init', 'car_taxonomy', 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment