• lanangedan

    (@lanangedan)


    Please help me.

    I have many question about wordpress.

    (1) I want to make a new database table with plugins
    (2) I want to make new field in my post page (custom field)
    but

    (3) How i can insert that post value into my own new database table. not into postmeta table.

    please help me. i think just here i can sovle my problem.

    *by the way, sorry for my english.

Viewing 1 replies (of 1 total)
  • luckdragon

    (@luckdragon)

    1, you mean that you want a plugin to create a table?

    function yourplugin_activate() {
      global $wpdb;
    
    $query = "Create Table ".$wpdb->prefix."yourtablename ('id' int(11) not null auto_increment,'nextfield' varchar(25) not null default '',primary key ('id'))";
    
      require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
      dbDelta($query);
    }
    register_activation_hook( __FILE__, "yourplugin_activate" );

    2,extra fields is what the postmeta table is for
    3, I’m not sure I fully understand what you are asking, but if you mean how do you insert your custom data into your custom table, there’s a hook for that
    add_action(‘save_post’,’your function here’);

    then you put your commands to save the data you want to save in your function

Viewing 1 replies (of 1 total)

The topic ‘How to Create database table,make new post field (custom)’ is closed to new replies.