dop20345 2017-06-12 12:36
浏览 200

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

I have custom post type -- Team how to create custom table for this post type help me I have created Custom post type but it does not insert any wordpress table. I want to create custom table in phpmyadmin and insert the post data like Id, date, post name etc in custom table. How can i do this please help me.

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' );

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 树莓派安卓APK系统签名
    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗