文章目录
分享文章
// 为页面创建自定义分类法
function custom_page_categories() {
    $labels = array(
        // 省略其他标签设置
    );

    $args = array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'show_admin_column' => true,
        'query_var' => true,
        'rewrite' => array('slug' => 'page-category'),
        // 添加以下设置
       'show_in_rest' => true,
    );

    register_taxonomy('page_category', array('page'), $args);
}
add_action('init', 'custom_page_categories', 0);

// 为页面创建自定义标签
function custom_page_tags() {
    $labels = array(
        // 省略其他标签设置
    );

    $args = array(
        'hierarchical' => false,
        'labels' => $labels,
        'show_ui' => true,
        'show_admin_column' => true,
        'update_count_callback' => '_update_post_term_count',
        'query_var' => true,
        'rewrite' => array('slug' => 'page-tag'),
        // 添加以下设置
       'show_in_rest' => true,
    );

    register_taxonomy('page_tag', 'page', $args);
}
add_action('init', 'custom_page_tags', 0);

使用wordpress从0-1搭建企业网站

WordPress是一个以PHP和MySQL为平台的自由开源的博客软件和内容管理系统,全球又43%的网站都在使用Wordpress进行网站制作。即使你是小白,也可以通过我的教程,从0-1制作属于自己的独立网站。

chenglulu

欢迎订阅

订阅我们的免费时事通讯

Leave A Comment