Codex

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

Function Reference/get default post to edit

This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_default_post_to_edit/

Description

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.

Usage

<code style="color: #000000"><span style="color: #0000BB"><?php get_default_post_to_edit</span><span style="color: #007700">( </span><span style="color: #0000BB">$post_type</span><span style="color: #007700">, </span><span style="color: #0000BB">$create_in_db </span><span style="color: #007700">); </span><span style="color: #0000BB">?></span></code>

Parameters

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

Return Values

(object) 
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