如何为wordpress数据库创建自定义表并在其中存储自定义帖子?

时间:2017-06-12 12:36:37

标签: php wordpress phpmyadmin

我有自定义帖子类型 - 团队 如何为此帖子类型创建自定义表 帮帮我我创建了自定义帖子类型,但它没有插入任何wordpress表。我想在phpmyadmin中创建自定义表,并在自定义表中插入像Id,日期,帖子名称等的帖子数据。我该怎么做才能帮助我。

function team_post_init() {
   
    $labels = array(
        'name' => ' All Teams',
        'singular_name' => 'Product',
        'add_new' => 'Add New Team',
        'add_new_item' => 'Add New Team',
        'edit_item' => 'Edit Team',
        'new_item' => 'New Team',
        'all_items' => 'All Teams',
        'view_item' => 'View Team',
        'search_items' => 'Search Teams',
        'not_found' =>  'No Teams Found',
        'not_found_in_trash' => 'No Teams found in Trash', 
        'parent_item_colon' => '',
        'menu_name' => 'Teams',
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'has_archive' => true,
        'show_ui' => true,
        'show_admin_column' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'rewrite' => array('slug' => 'team'),
        'query_var' => true,
        'show_in_rest' => true,
        'rest_base' => 'team',
        'rest_controller_class' =>'WP_REST_Posts_Controller',
        
        'supports' => array(
            'title',
            'editor',
            'excerpt',
            'trackbacks',
            'comments',
            'revisions',
            'thumbnail',
            'author',
            'page-attributes'
        )
    );
  register_post_type( 'team', $args);
    
  register_taxonomy('product_category', 'team', array('hierarchical' => true, 'label' => 'Category', 'query_var' => true, 'rewrite' => array( 'slug' => 'product-category' )));
}

add_action( 'init', 'team_post_init' );

0 个答案:

没有答案