| | 316 | * Update data from a post field based on Post ID. |
| | 317 | * |
| | 318 | * Examples of the post field will be, 'post_type', 'post_status', 'post_content', etc. |
| | 319 | * |
| | 320 | * The context values are based off of the taxonomy filter functions and |
| | 321 | * supported values are found within those functions. |
| | 322 | * |
| | 323 | * @since 2.9.0 |
| | 324 | * @uses sanitize_post_field() |
| | 325 | * |
| | 326 | * @param string $field Post field name |
| | 327 | * @param id $post Post ID |
| | 328 | * @return bool Result of UPDATE query |
| | 329 | */ |
| | 330 | function set_post_field($field, $value, $post_id) { |
| | 331 | global $wpdb; |
| | 332 | |
| | 333 | $post_id = absint($post_id); |
| | 334 | $value = sanitize_post_field($field, $value, $post_id, 'db'); |
| | 335 | |
| | 336 | return $wpdb->update($wpdb->posts, array($field => $value), array('ID' => $post_id)); |
| | 337 | } |
| | 338 | |
| | 339 | /** |