update_custom_table_field()

Insert or update data in a custom table

Parameters

update_custom_table_field( $custom_table_name, $values, [$post_id] )
  • $custom_table_name (string) (Required) The custom table name
  • $values (array) (Required) Data in an associative array format (key = column name, value = column value)
  • $post_id (mixed) (Optional) The post ID where the value is saved. Defaults to the current post.

Example

Update data of the current post

$data = array(
	'name' => 'iPhone',
	'price' => '$999'
);

update_custom_table_field( 'wp_products', $data);

Update data of a specific post

$data = array(
	'name' => 'iPhone',
	'price' => '$999'
);

update_custom_table_field( 'wp_products', $data, 123);

Upgrade to PRO