Taxonomie personnalisée spécifique à un type de publication personnalisée
1 réponses
- votes
c'est-à-direenregistrer unetaxonomiepersonnalisée MY_NEW_CARSS
pour lestypes depublicationpersonnalisés:
$my_taxon_name = 'MY_NEW_CARSS';
$my_post_types = array('SUB_CAT_1','SUB_CAT_2','SUB_CAT_3');
//REGISTER CUSTOM TAXONOMY ( http://codex.wordpress.org/Function_Reference/register_taxonomy )
//If you aim to register HIERARCHICAL(Parent-ed) post type, read this warning: https://codex.wordpress.org/Function_Reference/register_post_type#hierarchical
add_action( 'init', 'my_f32' ); function my_f32() {
register_taxonomy( $GLOBALS['my_taxon_name'], array(),
array(
'label'=>$GLOBALS['my_taxon_name'], 'public'=>true, 'show_ui'=>true, 'show_admin_column'=>true, 'query_var'=>true,
'hierarchical'=>true, 'rewrite'=>array('with_front'=>true,'hierarchical'=>true),
));
}
//REGISTER CUSTOM POST TYPE ( http://codex.wordpress.org/Function_Reference/register_post_type )
add_action( 'init', 'myf_63' );function myf_63() {
foreach ($GLOBALS['my_post_types'] as $each_Type) {
register_post_type( $each_Type,
array(
'label'=>$each_Type, 'labels' => array('name'=>$each_Type.' pagess', 'singular_name'=>$each_Type.' page'), 'public' => true, 'publicly_queryable'=> true, 'show_ui'=>true, 'capability_type' => 'post', 'has_archive' => true, 'query_var'=> true, 'can_export' => true, //'exclude_from_search' => false, 'show_in_nav_menus' => true, 'show_in_menu' => 'edit.php?post_type=page',//true, 'menu_position' => 5,
'hierarchical' =>true,
'supports' =>array( 'page-attributes', 'title', 'editor', 'thumbnail' ),
'rewrite' => array('with_front'=>true, ), // 'rewrite' => array("ep_mask"=>EP_PERMALINK ...) OR 'permalink_epmask'=>EP_PERMALINK,
));
register_taxonomy_for_object_type('category',$each_Type); //standard categories
register_taxonomy_for_object_type($GLOBALS['my_taxon_name'] ,$each_Type); //Custom categories
}
}
i.e. register a custom taxonomy MY_NEW_CARSS
for custom post types:
$my_taxon_name = 'MY_NEW_CARSS';
$my_post_types = array('SUB_CAT_1','SUB_CAT_2','SUB_CAT_3');
//REGISTER CUSTOM TAXONOMY ( http://codex.wordpress.org/Function_Reference/register_taxonomy )
//If you aim to register HIERARCHICAL(Parent-ed) post type, read this warning: https://codex.wordpress.org/Function_Reference/register_post_type#hierarchical
add_action( 'init', 'my_f32' ); function my_f32() {
register_taxonomy( $GLOBALS['my_taxon_name'], array(),
array(
'label'=>$GLOBALS['my_taxon_name'], 'public'=>true, 'show_ui'=>true, 'show_admin_column'=>true, 'query_var'=>true,
'hierarchical'=>true, 'rewrite'=>array('with_front'=>true,'hierarchical'=>true),
));
}
//REGISTER CUSTOM POST TYPE ( http://codex.wordpress.org/Function_Reference/register_post_type )
add_action( 'init', 'myf_63' );function myf_63() {
foreach ($GLOBALS['my_post_types'] as $each_Type) {
register_post_type( $each_Type,
array(
'label'=>$each_Type, 'labels' => array('name'=>$each_Type.' pagess', 'singular_name'=>$each_Type.' page'), 'public' => true, 'publicly_queryable'=> true, 'show_ui'=>true, 'capability_type' => 'post', 'has_archive' => true, 'query_var'=> true, 'can_export' => true, //'exclude_from_search' => false, 'show_in_nav_menus' => true, 'show_in_menu' => 'edit.php?post_type=page',//true, 'menu_position' => 5,
'hierarchical' =>true,
'supports' =>array( 'page-attributes', 'title', 'editor', 'thumbnail' ),
'rewrite' => array('with_front'=>true, ), // 'rewrite' => array("ep_mask"=>EP_PERMALINK ...) OR 'permalink_epmask'=>EP_PERMALINK,
));
register_taxonomy_for_object_type('category',$each_Type); //standard categories
register_taxonomy_for_object_type($GLOBALS['my_taxon_name'] ,$each_Type); //Custom categories
}
}
Je souhaite créer unetaxonomiepersonnalisée qui se comporte demanière similaire autype depublication car une catégorie se comporte comme lespublicationspar défaut (sur labase de la structure/% category%/%postname%/permalien) afin que lespublications dans lalestypes depublication sont affichés comme www.example.com/custom-post-type/custom-taxonomy-name/post-name Je souhaite également que la zoneméta de la catégorie apparaisse uniquement lorsquenous ajoutons unnouveaumessagepar défautet non lorsquenous ajoutons unnouveaumessage dans letype depublicationpersonnaliséet que la zone detaxonomiepersonnaliséen'apparaît que lorsquenous ajoutons unnouveaumessagedans letype demessagepersonnaliséet non lorsquenous ajoutons unnouveaumessagepar défaut.