php Créationd'un自定义帖子类型
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Créationd'un自定义帖子类型相关的知识,希望对你有一定的参考价值。
<?php
/* Exemple avec un custom post type "Projet" */
function projet_custom_post_type() {
$labels = array(
'name' => _x( 'Projets', 'Post Type General Name'),
'singular_name' => _x( 'Projet', 'Post Type Singular Name'),
'menu_name' => __( 'Projets' ),
'parent_item_colon' => __( 'Projet parent' ),
'all_items' => __( 'Tous les projets' ),
'view_item' => __( 'Voir le projet' ),
'add_new_item' => __( 'Ajouter un projet' ),
'add_new' => __( 'Nouveau projet' ),
'edit_item' => __( 'Modifier le projet' ),
'update_item' => __( 'Mettre à jour le projet' ),
'search_items' => __( 'Rechercher un projet' ),
'not_found' => __( 'Pas de résultat' ),
'not_found_in_trash' => __( 'Aucun résultat dans la corbeille' )
);
$args = array(
'label' => __( 'Projets'),
'description' => __( 'Tous les projets'),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'custom-fields', ),
'taxonomies' => array( 'categories' ),
'hierarchical' => false,
'public' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'projets'),
'menu_icon' => 'dashicons-portfolio'
);
register_post_type( 'projets', $args );
}
add_action( 'init', 'projet_custom_post_type', 0 );
?>
以上是关于php Créationd'un自定义帖子类型的主要内容,如果未能解决你的问题,请参考以下文章