Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'init', 'my_custom_table1' );
- function my_custom_table1() {
- if ( ! class_exists( 'MB_Custom_Table_API' ) ) {
- return;
- }
- MB_Custom_Table_API::create( 'my_custom_table1', array(
- 'address' => 'TEXT NOT NULL',
- 'phone' => 'TEXT NOT NULL',
- 'email' => 'VARCHAR(20) NOT NULL',
- 'switch' => 'INT'
- ), array( 'email' ) );
- }
- add_filter( 'rwmb_meta_boxes', 'register_field_table' );
- function register_field_table( $meta_boxes ) {
- $meta_boxes[] = array(
- 'title' => 'Custom table fields',
- 'storage_type' => 'custom_table', // Important
- 'table' => 'my_custom_table1', // Your custom table name
- 'post_types' => 'post',
- 'fields' => array(
- array(
- 'id' => 'address',
- 'type' => 'text',
- 'name' => 'Address',
- ),
- array(
- 'id' => 'phone',
- 'type' => 'text',
- 'name' => 'Phone',
- ),
- array(
- 'id' => 'email',
- 'type' => 'email',
- 'name' => 'Email',
- ),
- array(
- 'id' => 'switch',
- 'type' => 'switch',
- 'name' => 'Switch',
- ),
- ),
- );
- return $meta_boxes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement