I have a custom script/plugin I am using for myself that creates a post along with some postmeta information. Right now, I have multiple $wpdb->insert
, but I would like to condense this down into one query. How would I do this?
Here is my current code:
$meta_table = $wpdb->prefix . 'postmeta';
$wpdb->insert(
$meta_table,
array(
'post_id' => $post_id, // Already defined
'meta_key' => 'client-pwd',
'meta_value' => $post_pwd // Already defined
)
);
$wpdb->insert(
$meta_table,
array(
'post_id' => $post_id,
'meta_key' => 'gallery-status',
'meta_value' => 'private'
)
);
$wpdb->insert(
$meta_table,
array(
'post_id' => $post_id,
'meta_key' => 'meta-description',
'meta_value' => 'Description...'
)
);
$wpdb->insert(
$meta_table,
array(
'post_id' => $post_id,
'meta_key' => 'can-purchase',
'meta_value' => 'yes'
)
);
$wpdb->insert(
$meta_table,
array(
'post_id' => $post_id,
'meta_key' => 'can-email',
'meta_value' => 'yes'
)
);
$wpdb->insert(
$meta_table,
array(
'post_id' => $post_id,
'meta_key' => 'can-download',
'meta_value' => 'yes'
)
);