en

wpseek.com
A WordPress-centric search engine for devs and theme authors


  |     Browse all


wp_insert_post [ WordPress Function ]

wp_insert_post ( $postarr, $wp_error = false )
Parameters:
  • array $postarr Elements that make up post to insert.
  • bool $wp_error Optional. Allow return of WP_Error on failure.
Uses:
Returns:
  • int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
Defined at:



Insert a post.

If the $postarr parameter has 'ID' set to a value, then post will be updated.

You can set the post date manually, but setting the values for 'post_date' and 'post_date_gmt' keys. You can close the comments or open the comments by setting the value for 'comment_status' key.

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.

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

0 User Note(s)

None yet. Be the first!

Add New ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics