wp_update_post [ WordPress Function ]
wp_update_post ( $postarr = array() )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: wp_update_user, wp_delete_post, wp_update_core, wp_update_term, wp_update_comment
Update a post with new post data.
The date does not have to be set for drafts. You can set the date and it will not be overridden.
Source
<?php
function wp_update_post($postarr = array()) {
if ( is_object($postarr) ) {
// non-escaped post was passed
$postarr = get_object_vars($postarr);
$postarr = add_magic_quotes($postarr);
}
// First, get all of the original fields
$post = wp_get_single_post($postarr['ID'], ARRAY_A);
// Escape data pulled from DB.
$post = add_magic_quotes($post);
// Passed post category list overwrites existing category list if not empty.
if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
&& 0 != count($postarr['post_category']) )
$post_cats = $postarr['post_category'];
else
$post_cats = $post['post_category'];
// Drafts shouldn't be assigned a date unless explicitly done so by the user
if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
('0000-00-00 00:00:00' == $post['post_date_gmt']) )
$clear_date = true;
else
$clear_date = false;
// Merge old and new fields with new fields overwriting old ones.
$postarr = array_merge($post, $postarr);
$postarr['post_category'] = $post_cats;
if ( $clear_date ) {
$postarr['post_date'] = current_time('mysql');
$postarr['post_date_gmt'] = '';
}
if ($postarr['post_type'] == 'attachment')
return wp_insert_attachment($postarr);
return wp_insert_post($postarr);
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/wp update post « WordPress Codex
Before calling wp_update_post() it is necessary to create an array to pass the necessary elements. Unlike wp_insert_post(), it is only necessary to pass the ID of ...
codex.wordpress.org - WordPress › Support » wp_update_post
Jan 30, 2012 ... I spent three hours already and cannot make it work. I am trying to update the post content using wp_update_post function, but it does not seem ...
wordpress.org - using wp_update_post on save_post - WordPress - Stack Exchange
Nov 9, 2011 ... The reason it's going to be infinite is that every time you save the post, it's calling change_year...which then calls wp_update_post ... which fires ...
wordpress.stackexchange.com - wp_update_post make custom field values disappear - Stack Overflow
This is because when you are updating the post the *wp_insert_post* function is used and there is "save_post"(1) action hook which is usually used ...
stackoverflow.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- godthor on "wp_insert_post & wp_update_post"
- godthor on "wp_insert_post & wp_update_post"
- godthor on "wp_insert_post & wp_update_post"
- godthor on "wp_insert_post & wp_update_post"
- godthor on "wp_insert_post & wp_update_post"
- natereist on "wp_insert_post & wp_update_post"
- godthor on "wp_insert_post & wp_update_post"
- iamronen on "wp_update_post stuck in loop?"
- blue-eyed-devil on "wp_update_post() not working"
- bigneno on "[Plugin: Quick Cache ( Speed Without Compromise )] wp_update_post() doesn't purge post cache"