About pods create table
-
I learned that I can create my own tables using PODS. (What are Advanced Content Types).
I want to set it up from function.php or something like that, not from the admin panel.
I was able to create the table, but what do I do if I want to change the columns?
Also, if I set it from function.php, I want to make it impossible to change it from the admin screen.
(like pods_register_type).
This is my current code.
Once created, the process is aborted because of an error.function create_custom_table_pod() { $pod_name = 'my_custom_test'; $pod = pods_api()->load_pod(array('name' => $pod_name)); if ($pod) return; $params = array( 'storage' => 'table', // カスタムテーブルストレージタイプを指定 'type' => 'pod', // コンテンツタイプ 'name' => $pod_name, // テーブル名 'label' => 'My Custom Table', 'public' => '1', 'fields' => array( array( 'name' => 'field_name', 'label' => 'Field Name', 'type' => 'text' ), // 他のフィールドをここに追加 ) ); // Pod を作成 $pod = pods_api()->save_pod($params); // Pod が正常に作成されたか確認 if (!is_wp_error($pod)) { echo 'Pod created successfully with ID: ' . $pod; } else { echo 'Error creating Pod: ' . $pod->get_error_message(); } // pods_register_type( $params['type'], $params['name'], $params ); } add_action('init', 'create_custom_table_pod');Also, it would be better if it could be used like the wp-mvc plugin.
My English is poor, so apologies if I’m rude.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘About pods create table’ is closed to new replies.