php 使用分类法注册新的帖子类型
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 使用分类法注册新的帖子类型相关的知识,希望对你有一定的参考价值。
<?php
if ( !post_type_exists( 'news' ) ) {
function register_news_type() {
$label_singular = 'New';
$label_plural = 'News';
register_post_type('news', [
'label' => 'News',
'labels' => [
'all_items' => 'Toutes les news en base de données',
'singular_name' => 'new',
'add_new_item' => 'Ajouter une nouvelle news',
'add_new' => 'Ajouter une nouvelle news',
],
'hierarchical' => true,
'description' => 'Permet d’ajouter des news',
'public' => true,
'menu_icon' => 'dashicons-welcome-write-blog',
'rewrite' => [
'with_front' => false,
],
'supports' => ['title', 'thumbnail', 'custom-fields']
]);
}
function news_categories_init() {
register_taxonomy(
'category',
'news',
[
'label' => __( 'Type de news' ),
'hierarchical' => true,
]
);
}
add_action('init', 'register_news_type');
add_action( 'init', 'news_categories_init' );
}
以上是关于php 使用分类法注册新的帖子类型的主要内容,如果未能解决你的问题,请参考以下文章
php 注册自定义帖子类型和分类
php Wordpress:注册新的自定义帖子类型
自定义帖子类型和分类法分页 404 错误
从 Wordpress 取消注册自定义帖子类型
php 自定义分类法帖子类型
php WP分类法属于帖子类型吗?