Skip to content

Instantly share code, notes, and snippets.

@marcboivin
Created March 7, 2011 13:26
Show Gist options
  • Save marcboivin/858502 to your computer and use it in GitHub Desktop.
Save marcboivin/858502 to your computer and use it in GitHub Desktop.
Un example de modèle en WordPress
<?php
/* Registering taxonomie */
add_action( 'init', 'register_bai_taxonomies' );
function register_bai_taxonomies()
{
// Les idées sont un type de post.
register_post_type('idee', array(
'label' => __('Idées'),
'singular_label' => __('Idée'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
'supports' => array('author', 'comments', 'custom-fields', 'editor', 'excerpt', 'title'),
));
register_taxonomy(
'statut',
array( 'idee' ),
array(
'public' => true,
'hierarchical' => true,
'labels' => array(
'name' => __('Statut de l\'idée'),
'singular_name' => __('Statut'),
'search_items' => __('Chercher dans les statuts'),
'all_items' => __('Tous les statuts'),
'parent_item' => __('Statut parent'),
'new_item_name' => __('Nom du nouveau statut'),
),
// Par défaut, manage_categories est seulement disponible aux
// usagers de rôle Editor/Animateur ou plus haut.
'capabilities' => array(
'manage_terms' => 'manage_categories',
'edit_terms' => 'manage_categories',
'delete_terms' => 'manage_categories',
'assign_terms' => 'manage_categories',
),
)
);
register_taxonomy(
'privee',
array( 'idee' ),
array(
'public' => false,
'hierarchical' => true,
'labels' => array(
'name' => __( 'Privée' ),
'singular_name' => __( 'Cacher le nom de l\'auteur?' ),
),
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment