wp insert post data

本主题由 hgta 创建于 2009-11-9 20:38:39

Plugin API/Filter Reference/wp insert post data

Contents
[hide]
1 Description
2 Usage
3 Parameters
4 Return Values
5 Examples
6 Notes
7 Change Log
8 Source File
9 Related
10 See Also
Description
A filter hook called by the wp_insert_post function prior to inserting into or updating the database.

Usage

<?php function filter_handler( $data , $postarr ){ ...... }

add_filter( 'wp_insert_post_data' , 'filter_handler' , '99' ); ?>


Parameters
$data
(array) (required) Sanitized post data.
Default: None
$postarr
(array) (required) Raw post data.
Default: None
Return Values
(array)
$data.
Examples

<?php
function filter_handler( $data , $postarr )
{
// do something with the post data
return $data;
}

add_filter( 'wp_insert_post_data' , 'filter_handler' , '99' );
?>


Notes
The defaults for the parameter $postarr are:

'post_status' - Default is 'draft'.
'post_type' - Default is 'post'.
'post_author' - Default is current user ID ($user_ID). The ID of the user who added the post.
'ping_status' - Default is the value in 'default_ping_status' option.
Whether the attachment can accept pings.
'post_parent' - Default is 0. Set this for the post it belongs to, if any.
'menu_order' - Default is 0. The order it is displayed.
'to_ping' - Whether to ping.
'pinged' - Default is empty string.
'post_password' - Default is empty string. The password to access the attachment.
'guid' - Global Unique ID for referencing the attachment.
'post_content_filtered' - Post content filtered.
'post_excerpt' - Post excerpt.
$data is:

'post_author',
'post_date',
'post_date_gmt',
'post_content',
'post_content_filtered',
'post_title',
'post_excerpt',
'post_status',
'post_type',
'comment_status',
'ping_status',
'post_password',
'post_name',
'to_ping',
'pinged',
'post_modified',
'post_modified_gmt',
'post_parent',
'menu_order',
'guid'

Change Log
(wp_insert_post) Since: 1.0.0

Source File
wp_insert_post is located in wp-includes/post.php.



http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data

放心注册,GeeKaa不会虚耗你半点时间,你只会发现更多乐趣。 立即注册