Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get default post to edit


Default post information to use when populating the "Write Post" form.

Before using this function for your own theme or plugin, be wary of these non-obvious implicit behaviors (as of 4.2.3):

  • The returned post will have a post_category member set, even if the $post_type does not use the category taxonomy.
  • This post_category value will be scalar, which causes warnings passed into wp_insert_post without additional manipulation.
  • Some of the post's fields will be pulled out of $_REQUEST if present, which may not be the intended goal.


<?php get_default_post_to_edit$post_type$create_in_db ); ?>


(string) (optional) A post type string, defaults to 'post'.
Default: post
(boolean) (optional)
Default: false

Return Values

stdClass object containing all the default post data as attributes

Change Log

Since: 2.0

Source File

get_default_post_to_edit() is located in wp-admin/includes/post.php