[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> post.php (summary)

Core Post API

File Size: 8073 lines (273 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 141 functions

  create_initial_post_types()
  get_attached_file()
  update_attached_file()
  _wp_relative_upload_path()
  get_children()
  get_extended()
  get_post()
  get_post_ancestors()
  get_post_field()
  get_post_mime_type()
  get_post_status()
  get_post_statuses()
  get_page_statuses()
  _wp_privacy_statuses()
  register_post_status()
  get_post_status_object()
  get_post_stati()
  is_post_type_hierarchical()
  post_type_exists()
  get_post_type()
  get_post_type_object()
  get_post_types()
  register_post_type()
  unregister_post_type()
  get_post_type_capabilities()
  _post_type_meta_capabilities()
  get_post_type_labels()
  _get_custom_object_labels()
  _add_post_type_submenus()
  add_post_type_support()
  remove_post_type_support()
  get_all_post_type_supports()
  post_type_supports()
  get_post_types_by_support()
  set_post_type()
  is_post_type_viewable()
  is_post_status_viewable()
  is_post_publicly_viewable()
  get_posts()
  add_post_meta()
  delete_post_meta()
  get_post_meta()
  update_post_meta()
  delete_post_meta_by_key()
  register_post_meta()
  unregister_post_meta()
  get_post_custom()
  get_post_custom_keys()
  get_post_custom_values()
  is_sticky()
  sanitize_post()
  sanitize_post_field()
  stick_post()
  unstick_post()
  _count_posts_cache_key()
  wp_count_posts()
  wp_count_attachments()
  get_post_mime_types()
  wp_match_mime_types()
  wp_post_mime_type_where()
  wp_delete_post()
  _reset_front_page_settings_for_post()
  wp_trash_post()
  wp_untrash_post()
  wp_trash_post_comments()
  wp_untrash_post_comments()
  wp_get_post_categories()
  wp_get_post_tags()
  wp_get_post_terms()
  wp_get_recent_posts()
  wp_insert_post()
  wp_update_post()
  wp_publish_post()
  check_and_publish_future_post()
  wp_resolve_post_date()
  wp_unique_post_slug()
  _truncate_post_slug()
  wp_add_post_tags()
  wp_set_post_tags()
  wp_set_post_terms()
  wp_set_post_categories()
  wp_transition_post_status()
  wp_after_insert_post()
  add_ping()
  get_enclosed()
  get_pung()
  get_to_ping()
  trackback_url_list()
  get_all_page_ids()
  get_page()
  get_page_by_path()
  get_page_by_title()
  get_page_children()
  get_page_hierarchy()
  _page_traverse_name()
  get_page_uri()
  get_pages()
  is_local_attachment()
  wp_insert_attachment()
  wp_delete_attachment()
  wp_delete_attachment_files()
  wp_get_attachment_metadata()
  wp_update_attachment_metadata()
  wp_get_attachment_url()
  wp_get_attachment_caption()
  wp_get_attachment_thumb_file()
  wp_get_attachment_thumb_url()
  wp_attachment_is()
  wp_attachment_is_image()
  wp_mime_type_icon()
  wp_check_for_changed_slugs()
  wp_check_for_changed_dates()
  get_private_posts_cap_sql()
  get_posts_by_author_sql()
  get_lastpostdate()
  get_lastpostmodified()
  _get_last_post_time()
  update_post_cache()
  clean_post_cache()
  update_post_caches()
  update_postmeta_cache()
  clean_attachment_cache()
  _transition_post_status()
  _future_post_hook()
  _publish_post_hook()
  wp_get_post_parent_id()
  wp_check_post_hierarchy_for_loops()
  set_post_thumbnail()
  delete_post_thumbnail()
  wp_delete_auto_drafts()
  wp_queue_posts_for_term_meta_lazyload()
  _update_term_count_on_transition_post_status()
  _prime_post_caches()
  wp_add_trashed_suffix_to_post_name_for_trashed_posts()
  wp_add_trashed_suffix_to_post_name_for_post()
  _filter_query_attachment_filenames()
  wp_cache_set_posts_last_changed()
  get_available_post_mime_types()
  wp_get_original_image_path()
  wp_get_original_image_url()
  wp_untrash_post_set_previous_status()

Functions
Functions that are not part of a class:

create_initial_post_types()   X-Ref
Creates the initial post types when 'init' action is fired.

See {@see 'init'}.

since: 2.9.0

get_attached_file( $attachment_id, $unfiltered = false )   X-Ref
Retrieve attached file path based on attachment ID.

By default the path will go through the 'get_attached_file' filter, but
passing a true to the $unfiltered argument of get_attached_file() will
return the file path unfiltered.

The function works by getting the single post meta name, named
'_wp_attached_file' and returning it. This is a convenience function to
prevent looking up the meta name and provide a mechanism for sending the
attached filename through a filter.

since: 2.0.0
return: string|false The file path to where the attached file should be, false otherwise.
param: int  $attachment_id Attachment ID.
param: bool $unfiltered    Optional. Whether to apply filters. Default false.

update_attached_file( $attachment_id, $file )   X-Ref
Update attachment file path based on attachment ID.

Used to update the file path of the attachment, which uses post meta name
'_wp_attached_file' to store the path of the attachment.

since: 2.1.0
return: bool True on success, false on failure.
param: int    $attachment_id Attachment ID.
param: string $file          File path for the attachment.

_wp_relative_upload_path( $path )   X-Ref
Return relative path to an uploaded file.

The path is relative to the current upload dir.

since: 2.9.0
return: string Relative path on success, unchanged path on failure.
param: string $path Full path to the file.

get_children( $args = '', $output = OBJECT )   X-Ref
Retrieve all children of the post parent ID.

Normally, without any enhancements, the children would apply to pages. In the
context of the inner workings of WordPress, pages, posts, and attachments
share the same table, so therefore the functionality could apply to any one
of them. It is then noted that while this function does not work on posts, it
does not mean that it won't work on posts. It is recommended that you know
what context you wish to retrieve the children of.

Attachments may also be made the child of a post, so if that is an accurate
statement (which needs to be verified), it would then be possible to get
all of the attachments for a post. Attachments have since changed since
version 2.5, so this is most likely inaccurate, but serves generally as an
example of what is possible.

The arguments listed as defaults are for this function and also of the
get_posts() function. The arguments are combined with the get_children defaults
and are then passed to the get_posts() function, which accepts additional arguments.
You can replace the defaults in this function, listed below and the additional
arguments listed in the get_posts() function.

The 'post_parent' is the most important argument and important attention
needs to be paid to the $args parameter. If you pass either an object or an
integer (number), then just the 'post_parent' is grabbed and everything else
is lost. If you don't specify any arguments, then it is assumed that you are
in The Loop and the post parent will be grabbed for from the current post.

The 'post_parent' argument is the ID to get the children. The 'numberposts'
is the amount of posts to retrieve that has a default of '-1', which is
used to get all of the posts. Giving a number higher than 0 will only
retrieve that amount of posts.

The 'post_type' and 'post_status' arguments can be used to choose what
criteria of posts to retrieve. The 'post_type' can be anything, but WordPress
post types are 'post', 'pages', and 'attachments'. The 'post_status'
argument will accept any post status within the write administration panels.

since: 2.0.0
return: WP_Post[]|int[] Array of post objects or post IDs.
param: mixed  $args   Optional. User defined arguments for replacing the defaults. Default empty.
param: string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which

get_extended( $post )   X-Ref
Get extended entry info (<!--more-->).

There should not be any space after the second dash and before the word
'more'. There can be text or space(s) after the word 'more', but won't be
referenced.

The returned array has 'main', 'extended', and 'more_text' keys. Main has the text before
the `<!--more-->`. The 'extended' key has the content after the
`<!--more-->` comment. The 'more_text' key has the custom "Read More" text.

since: 1.0.0
return: string[] {
param: string $post Post content.

get_post( $post = null, $output = OBJECT, $filter = 'raw' )   X-Ref
Retrieves post data given a post ID or post object.

See sanitize_post() for optional $filter values. Also, the parameter
`$post`, must be given as a variable, since it is passed by reference.

since: 1.5.1
return: WP_Post|array|null Type corresponding to $output on success or null on failure.
param: int|WP_Post|null $post   Optional. Post ID or post object. `null`, `false`, `0` and other PHP falsey values
param: string           $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
param: string           $filter Optional. Type of filter to apply. Accepts 'raw', 'edit', 'db',

get_post_ancestors( $post )   X-Ref
Retrieves the IDs of the ancestors of a post.

since: 2.5.0
return: int[] Array of ancestor IDs or empty array if there are none.
param: int|WP_Post $post Post ID or post object.

get_post_field( $field, $post = null, $context = 'display' )   X-Ref
Retrieve data from a post field based on Post ID.

Examples of the post field will be, 'post_type', 'post_status', 'post_content',
etc and based off of the post object property or key names.

The context values are based off of the taxonomy filter functions and
supported values are found within those functions.

since: 2.3.0
since: 4.5.0 The `$post` parameter was made optional.
return: string The value of the post field on success, empty string on failure.
param: string      $field   Post field name.
param: int|WP_Post $post    Optional. Post ID or post object. Defaults to global $post.
param: string      $context Optional. How to filter the field. Accepts 'raw', 'edit', 'db',

get_post_mime_type( $post = null )   X-Ref
Retrieve the mime type of an attachment based on the ID.

This function can be used with any post type, but it makes more sense with
attachments.

since: 2.0.0
return: string|false The mime type on success, false on failure.
param: int|WP_Post $post Optional. Post ID or post object. Defaults to global $post.

get_post_status( $post = null )   X-Ref
Retrieve the post status based on the post ID.

If the post ID is of an attachment, then the parent post status will be given
instead.

since: 2.0.0
return: string|false Post status on success, false on failure.
param: int|WP_Post $post Optional. Post ID or post object. Defaults to global $post.

get_post_statuses()   X-Ref
Retrieve all of the WordPress supported post statuses.

Posts have a limited set of valid status values, this provides the
post_status values and descriptions.

since: 2.5.0
return: string[] Array of post status labels keyed by their status.

get_page_statuses()   X-Ref
Retrieve all of the WordPress support page statuses.

Pages have a limited set of valid status values, this provides the
post_status values and descriptions.

since: 2.5.0
return: string[] Array of page status labels keyed by their status.

_wp_privacy_statuses()   X-Ref
Return statuses for privacy requests.

since: 4.9.6
return: array

register_post_status( $post_status, $args = array()   X-Ref
Register a post status. Do not use before init.

A simple function for creating or modifying a post status based on the
parameters given. The function will accept an array (second optional
parameter), along with a string for the post status name.

Arguments prefixed with an _underscore shouldn't be used by plugins and themes.

since: 3.0.0
return: object
param: string       $post_status Name of the post status.
param: array|string $args {

get_post_status_object( $post_status )   X-Ref
Retrieve a post status object by name.

since: 3.0.0
return: stdClass|null A post status object.
param: string $post_status The name of a registered post status.

get_post_stati( $args = array()   X-Ref
Get a list of post statuses.

since: 3.0.0
return: string[]|stdClass[] A list of post status names or objects.
param: array|string $args     Optional. Array or string of post status arguments to compare against
param: string       $output   Optional. The type of output to return, either 'names' or 'objects'. Default 'names'.
param: string       $operator Optional. The logical operation to perform. 'or' means only one element

is_post_type_hierarchical( $post_type )   X-Ref
Whether the post type is hierarchical.

A false return value might also mean that the post type does not exist.

since: 3.0.0
return: bool Whether post type is hierarchical.
param: string $post_type Post type name

post_type_exists( $post_type )   X-Ref
Determines whether a post type is registered.

For more information on this and similar theme functions, check out
the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
Conditional Tags} article in the Theme Developer Handbook.

since: 3.0.0
return: bool Whether post type is registered.
param: string $post_type Post type name.

get_post_type( $post = null )   X-Ref
Retrieves the post type of the current post or of a given post.

since: 2.1.0
return: string|false          Post type on success, false on failure.
param: int|WP_Post|null $post Optional. Post ID or post object. Default is global $post.

get_post_type_object( $post_type )   X-Ref
Retrieves a post type object by name.

since: 3.0.0
since: 4.6.0 Object returned is now an instance of `WP_Post_Type`.
return: WP_Post_Type|null WP_Post_Type object if it exists, null otherwise.
param: string $post_type The name of a registered post type.

get_post_types( $args = array()   X-Ref
Get a list of all registered post type objects.

since: 2.9.0
return: string[]|WP_Post_Type[] An array of post type names or objects.
param: array|string $args     Optional. An array of key => value arguments to match against
param: string       $output   Optional. The type of output to return. Accepts post type 'names'
param: string       $operator Optional. The logical operation to perform. 'or' means only one

register_post_type( $post_type, $args = array()   X-Ref
Registers a post type.

Note: Post type registrations should not be hooked before the
{@see 'init'} action. Also, any taxonomy connections should be
registered via the `$taxonomies` argument to ensure consistency
when hooks such as {@see 'parse_query'} or {@see 'pre_get_posts'}
are used.

Post types can support any number of built-in core features such
as meta boxes, custom fields, post thumbnails, post statuses,
comments, and more. See the `$supports` argument for a complete
list of supported features.

since: 2.9.0
since: 3.0.0 The `show_ui` argument is now enforced on the new post screen.
since: 4.4.0 The `show_ui` argument is now enforced on the post type listing
since: 4.6.0 Post type object returned is now an instance of `WP_Post_Type`.
since: 4.7.0 Introduced `show_in_rest`, `rest_base` and `rest_controller_class`
since: 5.0.0 The `template` and `template_lock` arguments were added.
since: 5.3.0 The `supports` argument will now accept an array of arguments for a feature.
since: 5.9.0 The `rest_namespace` argument was added.
return: WP_Post_Type|WP_Error The registered post type object on success,
param: string       $post_type Post type key. Must not exceed 20 characters and may
param: array|string $args {

unregister_post_type( $post_type )   X-Ref
Unregisters a post type.

Cannot be used to unregister built-in post types.

since: 4.5.0
return: true|WP_Error True on success, WP_Error on failure or if the post type doesn't exist.
param: string $post_type Post type to unregister.

get_post_type_capabilities( $args )   X-Ref
Build an object with all post type capabilities out of a post type object

Post type capabilities use the 'capability_type' argument as a base, if the
capability is not set in the 'capabilities' argument array or if the
'capabilities' argument is not supplied.

The capability_type argument can optionally be registered as an array, with
the first value being singular and the second plural, e.g. array('story, 'stories')
Otherwise, an 's' will be added to the value for the plural form. After
registration, capability_type will always be a string of the singular value.

By default, eight keys are accepted as part of the capabilities array:

- edit_post, read_post, and delete_post are meta capabilities, which are then
generally mapped to corresponding primitive capabilities depending on the
context, which would be the post being edited/read/deleted and the user or
role being checked. Thus these capabilities would generally not be granted
directly to users or roles.

- edit_posts - Controls whether objects of this post type can be edited.
- edit_others_posts - Controls whether objects of this type owned by other users
can be edited. If the post type does not support an author, then this will
behave like edit_posts.
- delete_posts - Controls whether objects of this post type can be deleted.
- publish_posts - Controls publishing objects of this post type.
- read_private_posts - Controls whether private objects can be read.

These five primitive capabilities are checked in core in various locations.
There are also six other primitive capabilities which are not referenced
directly in core, except in map_meta_cap(), which takes the three aforementioned
meta capabilities and translates them into one or more primitive capabilities
that must then be checked against the user or role, depending on the context.

- read - Controls whether objects of this post type can be read.
- delete_private_posts - Controls whether private objects can be deleted.
- delete_published_posts - Controls whether published objects can be deleted.
- delete_others_posts - Controls whether objects owned by other users can be
can be deleted. If the post type does not support an author, then this will
behave like delete_posts.
- edit_private_posts - Controls whether private objects can be edited.
- edit_published_posts - Controls whether published objects can be edited.

These additional capabilities are only used in map_meta_cap(). Thus, they are
only assigned by default if the post type is registered with the 'map_meta_cap'
argument set to true (default is false).

since: 3.0.0
since: 5.4.0 'delete_posts' is included in default capabilities.
return: object Object with all the capabilities as member variables.
param: object $args Post type registration arguments.

_post_type_meta_capabilities( $capabilities = null )   X-Ref
Store or return a list of post type meta caps for map_meta_cap().

since: 3.1.0
param: string[] $capabilities Post type meta capabilities.

get_post_type_labels( $post_type_object )   X-Ref
Builds an object with all post type labels out of a post type object.

Accepted keys of the label array in the post type object:

- `name` - General name for the post type, usually plural. The same and overridden
by `$post_type_object->label`. Default is 'Posts' / 'Pages'.
- `singular_name` - Name for one object of this post type. Default is 'Post' / 'Page'.
- `add_new` - Default is 'Add New' for both hierarchical and non-hierarchical types.
When internationalizing this string, please use a {@link https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#disambiguation-by-context gettext context}
matching your post type. Example: `_x( 'Add New', 'product', 'textdomain' );`.
- `add_new_item` - Label for adding a new singular item. Default is 'Add New Post' / 'Add New Page'.
- `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'.
- `new_item` - Label for the new item page title. Default is 'New Post' / 'New Page'.
- `view_item` - Label for viewing a singular item. Default is 'View Post' / 'View Page'.
- `view_items` - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
- `search_items` - Label for searching plural items. Default is 'Search Posts' / 'Search Pages'.
- `not_found` - Label used when no items are found. Default is 'No posts found' / 'No pages found'.
- `not_found_in_trash` - Label used when no items are in the Trash. Default is 'No posts found in Trash' /
'No pages found in Trash'.
- `parent_item_colon` - Label used to prefix parents of hierarchical items. Not used on non-hierarchical
post types. Default is 'Parent Page:'.
- `all_items` - Label to signify all items in a submenu link. Default is 'All Posts' / 'All Pages'.
- `archives` - Label for archives in nav menus. Default is 'Post Archives' / 'Page Archives'.
- `attributes` - Label for the attributes meta box. Default is 'Post Attributes' / 'Page Attributes'.
- `insert_into_item` - Label for the media frame button. Default is 'Insert into post' / 'Insert into page'.
- `uploaded_to_this_item` - Label for the media frame filter. Default is 'Uploaded to this post' /
'Uploaded to this page'.
- `featured_image` - Label for the featured image meta box title. Default is 'Featured image'.
- `set_featured_image` - Label for setting the featured image. Default is 'Set featured image'.
- `remove_featured_image` - Label for removing the featured image. Default is 'Remove featured image'.
- `use_featured_image` - Label in the media frame for using a featured image. Default is 'Use as featured image'.
- `menu_name` - Label for the menu name. Default is the same as `name`.
- `filter_items_list` - Label for the table views hidden heading. Default is 'Filter posts list' /
'Filter pages list'.
- `filter_by_date` - Label for the date filter in list tables. Default is 'Filter by date'.
- `items_list_navigation` - Label for the table pagination hidden heading. Default is 'Posts list navigation' /
'Pages list navigation'.
- `items_list` - Label for the table hidden heading. Default is 'Posts list' / 'Pages list'.
- `item_published` - Label used when an item is published. Default is 'Post published.' / 'Page published.'
- `item_published_privately` - Label used when an item is published with private visibility.
Default is 'Post published privately.' / 'Page published privately.'
- `item_reverted_to_draft` - Label used when an item is switched to a draft.
Default is 'Post reverted to draft.' / 'Page reverted to draft.'
- `item_scheduled` - Label used when an item is scheduled for publishing. Default is 'Post scheduled.' /
'Page scheduled.'
- `item_updated` - Label used when an item is updated. Default is 'Post updated.' / 'Page updated.'
- `item_link` - Title for a navigation link block variation. Default is 'Post Link' / 'Page Link'.
- `item_link_description` - Description for a navigation link block variation. Default is 'A link to a post.' /
'A link to a page.'

Above, the first default value is for non-hierarchical post types (like posts)
and the second one is for hierarchical post types (like pages).

Note: To set labels used in post type admin notices, see the {@see 'post_updated_messages'} filter.

since: 3.0.0
since: 4.3.0 Added the `featured_image`, `set_featured_image`, `remove_featured_image`,
since: 4.4.0 Added the `archives`, `insert_into_item`, `uploaded_to_this_item`, `filter_items_list`,
since: 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
since: 4.7.0 Added the `view_items` and `attributes` labels.
since: 5.0.0 Added the `item_published`, `item_published_privately`, `item_reverted_to_draft`,
since: 5.7.0 Added the `filter_by_date` label.
since: 5.8.0 Added the `item_link` and `item_link_description` labels.
return: object Object with all the labels as member variables.
param: object|WP_Post_Type $post_type_object Post type object.

_get_custom_object_labels( $object, $nohier_vs_hier_defaults )   X-Ref
Build an object with custom-something object (post type, taxonomy) labels
out of a custom-something object

since: 3.0.0
return: object Object containing labels for the given custom-something object.
param: object $object                  A custom-something object.
param: array  $nohier_vs_hier_defaults Hierarchical vs non-hierarchical default labels.

_add_post_type_submenus()   X-Ref
Add submenus for post types.

since: 3.1.0

add_post_type_support( $post_type, $feature, ...$args )   X-Ref
Registers support of certain features for a post type.

All core features are directly associated with a functional area of the edit
screen, such as the editor or a meta box. Features include: 'title', 'editor',
'comments', 'revisions', 'trackbacks', 'author', 'excerpt', 'page-attributes',
'thumbnail', 'custom-fields', and 'post-formats'.

Additionally, the 'revisions' feature dictates whether the post type will
store revisions, and the 'comments' feature dictates whether the comments
count will show on the edit screen.

A third, optional parameter can also be passed along with a feature to provide
additional information about supporting that feature.

Example usage:

add_post_type_support( 'my_post_type', 'comments' );
add_post_type_support( 'my_post_type', array(
'author', 'excerpt',
) );
add_post_type_support( 'my_post_type', 'my_feature', array(
'field' => 'value',
) );

since: 3.0.0
since: 5.3.0 Formalized the existing and already documented `...$args` parameter
param: string       $post_type The post type for which to add the feature.
param: string|array $feature   The feature being added, accepts an array of
param: mixed        ...$args   Optional extra arguments to pass along with certain features.

remove_post_type_support( $post_type, $feature )   X-Ref
Remove support for a feature from a post type.

since: 3.0.0
param: string $post_type The post type for which to remove the feature.
param: string $feature   The feature being removed.

get_all_post_type_supports( $post_type )   X-Ref
Get all the post type features

since: 3.4.0
return: array Post type supports list.
param: string $post_type The post type.

post_type_supports( $post_type, $feature )   X-Ref
Check a post type's support for a given feature.

since: 3.0.0
return: bool Whether the post type supports the given feature.
param: string $post_type The post type being checked.
param: string $feature   The feature being checked.

get_post_types_by_support( $feature, $operator = 'and' )   X-Ref
Retrieves a list of post type names that support a specific feature.

since: 4.5.0
return: string[] A list of post type names.
param: array|string $feature  Single feature or an array of features the post types should support.
param: string       $operator Optional. The logical operation to perform. 'or' means

set_post_type( $post_id = 0, $post_type = 'post' )   X-Ref
Update the post type for the post ID.

The page or post cache will be cleaned for the post ID.

since: 2.5.0
return: int|false Amount of rows changed. Should be 1 for success and 0 for failure.
param: int    $post_id   Optional. Post ID to change post type. Default 0.
param: string $post_type Optional. Post type. Accepts 'post' or 'page' to

is_post_type_viewable( $post_type )   X-Ref
Determines whether a post type is considered "viewable".

For built-in post types such as posts and pages, the 'public' value will be evaluated.
For all others, the 'publicly_queryable' value will be used.

since: 4.4.0
since: 4.5.0 Added the ability to pass a post type name in addition to object.
since: 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
since: 5.9.0 Added `is_post_type_viewable` hook to filter the result.
return: bool Whether the post type should be considered viewable.
param: string|WP_Post_Type $post_type Post type name or object.

is_post_status_viewable( $post_status )   X-Ref
Determine whether a post status is considered "viewable".

For built-in post statuses such as publish and private, the 'public' value will be evaluated.
For all others, the 'publicly_queryable' value will be used.

since: 5.7.0
since: 5.9.0 Added `is_post_status_viewable` hook to filter the result.
return: bool Whether the post status should be considered viewable.
param: string|stdClass $post_status Post status name or object.

is_post_publicly_viewable( $post = null )   X-Ref
Determine whether a post is publicly viewable.

Posts are considered publicly viewable if both the post status and post type
are viewable.

since: 5.7.0
return: bool Whether the post is publicly viewable.
param: int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.

get_posts( $args = null )   X-Ref
Retrieves an array of the latest posts, or posts matching the given criteria.

For more information on the accepted arguments, see the
{@link https://developer.wordpress.org/reference/classes/wp_query/
WP_Query} documentation in the Developer Handbook.

The `$ignore_sticky_posts` and `$no_found_rows` arguments are ignored by
this function and both are set to `true`.

The defaults are as follows:

since: 1.2.0
return: WP_Post[]|int[] Array of post objects or post IDs.
param: array $args {

add_post_meta( $post_id, $meta_key, $meta_value, $unique = false )   X-Ref
Adds a meta field to the given post.

Post meta data is called "Custom Fields" on the Administration Screen.

since: 1.5.0
return: int|false Meta ID on success, false on failure.
param: int    $post_id    Post ID.
param: string $meta_key   Metadata name.
param: mixed  $meta_value Metadata value. Must be serializable if non-scalar.
param: bool   $unique     Optional. Whether the same key should not be added.

delete_post_meta( $post_id, $meta_key, $meta_value = '' )   X-Ref
Deletes a post meta field for the given post ID.

You can match based on the key, or key and value. Removing based on key and
value, will keep from removing duplicate metadata with the same key. It also
allows removing all metadata matching the key, if needed.

since: 1.5.0
return: bool True on success, false on failure.
param: int    $post_id    Post ID.
param: string $meta_key   Metadata name.
param: mixed  $meta_value Optional. Metadata value. If provided,

get_post_meta( $post_id, $key = '', $single = false )   X-Ref
Retrieves a post meta field for the given post ID.

since: 1.5.0
return: mixed An array of values if `$single` is false.
param: int    $post_id Post ID.
param: string $key     Optional. The meta key to retrieve. By default,
param: bool   $single  Optional. Whether to return a single value.

update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' )   X-Ref
Updates a post meta field based on the given post ID.

Use the `$prev_value` parameter to differentiate between meta fields with the
same key and post ID.

If the meta field for the post does not exist, it will be added and its ID returned.

Can be used in place of add_post_meta().

since: 1.5.0
return: int|bool Meta ID if the key didn't exist, true on successful update,
param: int    $post_id    Post ID.
param: string $meta_key   Metadata key.
param: mixed  $meta_value Metadata value. Must be serializable if non-scalar.
param: mixed  $prev_value Optional. Previous value to check before updating.

delete_post_meta_by_key( $post_meta_key )   X-Ref
Deletes everything from post meta matching the given meta key.

since: 2.3.0
return: bool Whether the post meta key was deleted from the database.
param: string $post_meta_key Key to search for when deleting.

register_post_meta( $post_type, $meta_key, array $args )   X-Ref
Registers a meta key for posts.

since: 4.9.8
return: bool True if the meta key was successfully registered, false if not.
param: string $post_type Post type to register a meta key for. Pass an empty string
param: string $meta_key  The meta key to register.
param: array  $args      Data used to describe the meta key when registered. See

unregister_post_meta( $post_type, $meta_key )   X-Ref
Unregisters a meta key for posts.

since: 4.9.8
return: bool True on success, false if the meta key was not previously registered.
param: string $post_type Post type the meta key is currently registered for. Pass
param: string $meta_key  The meta key to unregister.

get_post_custom( $post_id = 0 )   X-Ref
Retrieve post meta fields, based on post ID.

The post meta fields are retrieved from the cache where possible,
so the function is optimized to be called more than once.

since: 1.2.0
return: mixed An array of values.
param: int $post_id Optional. Post ID. Default is the ID of the global `$post`.

get_post_custom_keys( $post_id = 0 )   X-Ref
Retrieve meta field names for a post.

If there are no meta fields, then nothing (null) will be returned.

since: 1.2.0
return: array|void Array of the keys, if retrieved.
param: int $post_id Optional. Post ID. Default is the ID of the global `$post`.

get_post_custom_values( $key = '', $post_id = 0 )   X-Ref
Retrieve values for a custom post field.

The parameters must not be considered optional. All of the post meta fields
will be retrieved and only the meta field key values returned.

since: 1.2.0
return: array|null Meta field values.
param: string $key     Optional. Meta field key. Default empty.
param: int    $post_id Optional. Post ID. Default is the ID of the global `$post`.

is_sticky( $post_id = 0 )   X-Ref
Determines whether a post is sticky.

Sticky posts should remain at the top of The Loop. If the post ID is not
given, then The Loop ID for the current post will be used.

For more information on this and similar theme functions, check out
the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
Conditional Tags} article in the Theme Developer Handbook.

since: 2.7.0
return: bool Whether post is sticky.
param: int $post_id Optional. Post ID. Default is the ID of the global `$post`.

sanitize_post( $post, $context = 'display' )   X-Ref
Sanitizes every post field.

If the context is 'raw', then the post object or array will get minimal
sanitization of the integer fields.

since: 2.3.0
return: object|WP_Post|array The now sanitized post object or array (will be the
param: object|WP_Post|array $post    The post object or array
param: string               $context Optional. How to sanitize post fields.

sanitize_post_field( $field, $value, $post_id, $context = 'display' )   X-Ref
Sanitizes a post field based on context.

Possible context values are:  'raw', 'edit', 'db', 'display', 'attribute' and
'js'. The 'display' context is used by default. 'attribute' and 'js' contexts
are treated like 'display' when calling filters.

since: 2.3.0
since: 4.4.0 Like `sanitize_post()`, `$context` defaults to 'display'.
return: mixed Sanitized value.
param: string $field   The Post Object field name.
param: mixed  $value   The Post Object value.
param: int    $post_id Post ID.
param: string $context Optional. How to sanitize the field. Possible values are 'raw', 'edit',

stick_post( $post_id )   X-Ref
Make a post sticky.

Sticky posts should be displayed at the top of the front page.

since: 2.7.0
param: int $post_id Post ID.

unstick_post( $post_id )   X-Ref
Un-stick a post.

Sticky posts should be displayed at the top of the front page.

since: 2.7.0
param: int $post_id Post ID.

_count_posts_cache_key( $type = 'post', $perm = '' )   X-Ref
Return the cache key for wp_count_posts() based on the passed arguments.

since: 3.9.0
return: string The cache key.
param: string $type Optional. Post type to retrieve count Default 'post'.
param: string $perm Optional. 'readable' or empty. Default empty.

wp_count_posts( $type = 'post', $perm = '' )   X-Ref
Count number of posts of a post type and if user has permissions to view.

This function provides an efficient method of finding the amount of post's
type a blog has. Another method is to count the amount of items in
get_posts(), but that method has a lot of overhead with doing so. Therefore,
when developing for 2.5+, use this function instead.

The $perm parameter checks for 'readable' value and if the user can read
private posts, it will display that for the user that is signed in.

since: 2.5.0
return: stdClass Number of posts for each status.
param: string $type Optional. Post type to retrieve count. Default 'post'.
param: string $perm Optional. 'readable' or empty. Default empty.

wp_count_attachments( $mime_type = '' )   X-Ref
Count number of attachments for the mime type(s).

If you set the optional mime_type parameter, then an array will still be
returned, but will only have the item you are looking for. It does not give
you the number of attachments that are children of a post. You can get that
by counting the number of children that post has.

since: 2.5.0
return: stdClass An object containing the attachment counts by mime type.
param: string|string[] $mime_type Optional. Array or comma-separated list of

get_post_mime_types()   X-Ref
Get default post mime types.

since: 2.9.0
since: 5.3.0 Added the 'Documents', 'Spreadsheets', and 'Archives' mime type groups.
return: array List of post mime types.

wp_match_mime_types( $wildcard_mime_types, $real_mime_types )   X-Ref
Check a MIME-Type against a list.

If the wildcard_mime_types parameter is a string, it must be comma separated
list. If the real_mime_types is a string, it is also comma separated to
create the list.

since: 2.5.0
return: array array(wildcard=>array(real types)).
param: string|string[] $wildcard_mime_types Mime types, e.g. audio/mpeg or image (same as image/*)
param: string|string[] $real_mime_types     Real post mime type values.

wp_post_mime_type_where( $post_mime_types, $table_alias = '' )   X-Ref
Convert MIME types into SQL.

since: 2.5.0
return: string The SQL AND clause for mime searching.
param: string|string[] $post_mime_types List of mime types or comma separated string
param: string          $table_alias     Optional. Specify a table alias, if needed.

wp_delete_post( $postid = 0, $force_delete = false )   X-Ref
Trash or delete a post or page.

When the post and page is permanently deleted, everything that is tied to
it is deleted also. This includes comments, post meta fields, and terms
associated with the post.

The post or page is moved to Trash instead of permanently deleted unless
Trash is disabled, item is already in the Trash, or $force_delete is true.

since: 1.0.0
return: WP_Post|false|null Post data on success, false or null on failure.
param: int  $postid       Optional. Post ID. Default 0.
param: bool $force_delete Optional. Whether to bypass Trash and force deletion.

_reset_front_page_settings_for_post( $post_id )   X-Ref
Reset the page_on_front, show_on_front, and page_for_post settings when
a linked page is deleted or trashed.

Also ensures the post is no longer sticky.

since: 3.7.0
param: int $post_id Post ID.

wp_trash_post( $post_id = 0 )   X-Ref
Move a post or page to the Trash

If Trash is disabled, the post or page is permanently deleted.

since: 2.9.0
return: WP_Post|false|null Post data on success, false or null on failure.
param: int $post_id Optional. Post ID. Default is the ID of the global `$post`

wp_untrash_post( $post_id = 0 )   X-Ref
Restores a post from the Trash.

since: 2.9.0
since: 5.6.0 An untrashed post is now returned to 'draft' status by default, except for
return: WP_Post|false|null Post data on success, false or null on failure.
param: int $post_id Optional. Post ID. Default is the ID of the global `$post`.

wp_trash_post_comments( $post = null )   X-Ref
Moves comments for a post to the Trash.

since: 2.9.0
return: mixed|void False on failure.
param: int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.

wp_untrash_post_comments( $post = null )   X-Ref
Restore comments for a post from the Trash.

since: 2.9.0
return: true|void
param: int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.

wp_get_post_categories( $post_id = 0, $args = array()   X-Ref
Retrieve the list of categories for a post.

Compatibility layer for themes and plugins. Also an easy layer of abstraction
away from the complexity of the taxonomy layer.

since: 2.1.0
return: array|WP_Error List of categories. If the `$fields` argument passed via `$args` is 'all' or
param: int   $post_id Optional. The Post ID. Does not default to the ID of the
param: array $args    Optional. Category query parameters. Default empty array.

wp_get_post_tags( $post_id = 0, $args = array()   X-Ref
Retrieve the tags for a post.

There is only one default for this function, called 'fields' and by default
is set to 'all'. There are other defaults that can be overridden in
wp_get_object_terms().

since: 2.3.0
return: array|WP_Error Array of WP_Term objects on success or empty array if no tags were found.
param: int   $post_id Optional. The Post ID. Does not default to the ID of the
param: array $args    Optional. Tag query parameters. Default empty array.

wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array()   X-Ref
Retrieves the terms for a post.

since: 2.8.0
return: array|WP_Error Array of WP_Term objects on success or empty array if no terms were found.
param: int             $post_id  Optional. The Post ID. Does not default to the ID of the
param: string|string[] $taxonomy Optional. The taxonomy slug or array of slugs for which
param: array           $args     {

wp_get_recent_posts( $args = array()   X-Ref
Retrieve a number of recent posts.

since: 1.0.0
return: array|false Array of recent posts, where the type of each element is determined
param: array  $args   Optional. Arguments to retrieve posts. Default empty array.
param: string $output Optional. The required return type. One of OBJECT or ARRAY_A, which

wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )   X-Ref
Insert or update a post.

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

You can set the post date manually, by 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.

since: 1.0.0
since: 2.6.0 Added the `$wp_error` parameter to allow a WP_Error to be returned on failure.
since: 4.2.0 Support was added for encoding emoji in the post title, content, and excerpt.
since: 4.4.0 A 'meta_input' array can now be passed to `$postarr` to add post meta data.
since: 5.6.0 Added the `$fire_after_hooks` parameter.
return: int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
param: array $postarr {
param: bool  $wp_error         Optional. Whether to return a WP_Error on failure. Default false.
param: bool  $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true.

wp_update_post( $postarr = array()   X-Ref
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.

since: 1.0.0
since: 3.5.0 Added the `$wp_error` parameter to allow a WP_Error to be returned on failure.
since: 5.6.0 Added the `$fire_after_hooks` parameter.
return: int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
param: array|object $postarr          Optional. Post data. Arrays are expected to be escaped,
param: bool         $wp_error         Optional. Whether to return a WP_Error on failure. Default false.
param: bool         $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true.

wp_publish_post( $post )   X-Ref
Publish a post by transitioning the post status.

since: 2.1.0
param: int|WP_Post $post Post ID or post object.

check_and_publish_future_post( $post_id )   X-Ref
Publish future post and make sure post ID has future post status.

Invoked by cron 'publish_future_post' event. This safeguard prevents cron
from publishing drafts, etc.

since: 2.5.0
param: int|WP_Post $post_id Post ID or post object.

wp_resolve_post_date( $post_date = '', $post_date_gmt = '' )   X-Ref
Uses wp_checkdate to return a valid Gregorian-calendar value for post_date.
If post_date is not provided, this first checks post_date_gmt if provided,
then falls back to use the current time.

For back-compat purposes in wp_insert_post, an empty post_date and an invalid
post_date_gmt will continue to return '1970-01-01 00:00:00' rather than false.

since: 5.7.0
return: string|false A valid Gregorian-calendar date string, or false on failure.
param: string $post_date     The date in mysql format.
param: string $post_date_gmt The GMT date in mysql format.

wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent )   X-Ref
Computes a unique slug for the post, when given the desired slug and some post details.

since: 2.8.0
return: string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
param: string $slug        The desired slug (post_name).
param: int    $post_ID     Post ID.
param: string $post_status No uniqueness checks are made if the post is still draft or pending.
param: string $post_type   Post type.
param: int    $post_parent Post parent ID.

_truncate_post_slug( $slug, $length = 200 )   X-Ref
Truncate a post slug.

since: 3.6.0
return: string The truncated slug.
param: string $slug   The slug to truncate.
param: int    $length Optional. Max length of the slug. Default 200 (characters).

wp_add_post_tags( $post_id = 0, $tags = '' )   X-Ref
Add tags to a post.

since: 2.3.0
return: array|false|WP_Error Array of affected term IDs. WP_Error or false on failure.
param: int          $post_id Optional. The Post ID. Does not default to the ID of the global $post.
param: string|array $tags    Optional. An array of tags to set for the post, or a string of tags

wp_set_post_tags( $post_id = 0, $tags = '', $append = false )   X-Ref
Set the tags for a post.

since: 2.3.0
return: array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
param: int          $post_id Optional. The Post ID. Does not default to the ID of the global $post.
param: string|array $tags    Optional. An array of tags to set for the post, or a string of tags
param: bool         $append  Optional. If true, don't delete existing tags, just add on. If false,

wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false )   X-Ref
Set the terms for a post.

since: 2.8.0
return: array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
param: int          $post_id  Optional. The Post ID. Does not default to the ID of the global $post.
param: string|array $tags     Optional. An array of terms to set for the post, or a string of terms
param: string       $taxonomy Optional. Taxonomy name. Default 'post_tag'.
param: bool         $append   Optional. If true, don't delete existing terms, just add on. If false,

wp_set_post_categories( $post_ID = 0, $post_categories = array()   X-Ref
Set categories for a post.

If no categories are provided, the default category is used.

since: 2.1.0
return: array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
param: int       $post_ID         Optional. The Post ID. Does not default to the ID
param: int[]|int $post_categories Optional. List of category IDs, or the ID of a single category.
param: bool      $append          If true, don't delete existing categories, just add on.

wp_transition_post_status( $new_status, $old_status, $post )   X-Ref
Fires actions related to the transitioning of a post's status.

When a post is saved, the post status is "transitioned" from one status to another,
though this does not always mean the status has actually changed before and after
the save. This function fires a number of action hooks related to that transition:
the generic {@see 'transition_post_status'} action, as well as the dynamic hooks
{@see '$old_status_to_$new_status'} and {@see '$new_status_$post->post_type'}. Note
that the function does not transition the post object in the database.

For instance: When publishing a post for the first time, the post status may transition
from 'draft' – or some other status – to 'publish'. However, if a post is already
published and is simply being updated, the "old" and "new" statuses may both be 'publish'
before and after the transition.

since: 2.3.0
param: string  $new_status Transition to this post status.
param: string  $old_status Previous post status.
param: WP_Post $post Post data.

wp_after_insert_post( $post, $update, $post_before )   X-Ref
Fires actions after a post, its terms and meta data has been saved.

since: 5.6.0
param: int|WP_Post  $post        The post ID or object that has been saved.
param: bool         $update      Whether this is an existing post being updated.
param: null|WP_Post $post_before Null for new posts, the WP_Post object prior

add_ping( $post_id, $uri )   X-Ref
Add a URL to those already pinged.

since: 1.5.0
since: 4.7.0 `$post_id` can be a WP_Post object.
since: 4.7.0 `$uri` can be an array of URIs.
return: int|false How many rows were updated.
param: int|WP_Post  $post_id Post object or ID.
param: string|array $uri     Ping URI or array of URIs.

get_enclosed( $post_id )   X-Ref
Retrieve enclosures already enclosed for a post.

since: 1.5.0
return: string[] Array of enclosures for the given post.
param: int $post_id Post ID.

get_pung( $post_id )   X-Ref
Retrieve URLs already pinged for a post.

since: 1.5.0
since: 4.7.0 `$post_id` can be a WP_Post object.
return: string[]|false Array of URLs already pinged for the given post, false if the post is not found.
param: int|WP_Post $post_id Post ID or object.

get_to_ping( $post_id )   X-Ref
Retrieve URLs that need to be pinged.

since: 1.5.0
since: 4.7.0 `$post_id` can be a WP_Post object.
return: string[]|false List of URLs yet to ping.
param: int|WP_Post $post_id Post Object or ID

trackback_url_list( $tb_list, $post_id )   X-Ref
Do trackbacks for a list of URLs.

since: 1.0.0
param: string $tb_list Comma separated list of URLs.
param: int    $post_id Post ID.

get_all_page_ids()   X-Ref
Get a list of page IDs.

since: 2.0.0
return: string[] List of page IDs as strings.

get_page( $page, $output = OBJECT, $filter = 'raw' )   X-Ref
Retrieves page data given a page ID or page object.

Use get_post() instead of get_page().

since: 1.5.1
return: WP_Post|array|null WP_Post or array on success, null on failure.
param: int|WP_Post $page   Page object or page ID. Passed by reference.
param: string      $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
param: string      $filter Optional. How the return value should be filtered. Accepts 'raw',

get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' )   X-Ref
Retrieves a page given its path.

since: 2.1.0
return: WP_Post|array|null WP_Post (or array) on success, or null on failure.
param: string       $page_path Page path.
param: string       $output    Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
param: string|array $post_type Optional. Post type or array of post types. Default 'page'.

get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' )   X-Ref
Retrieve a page given its title.

If more than one post uses the same title, the post with the smallest ID will be returned.
Be careful: in case of more than one post having the same title, it will check the oldest
publication date, not the smallest ID.

Because this function uses the MySQL '=' comparison, $page_title will usually be matched
as case-insensitive with default collation.

since: 2.1.0
since: 3.0.0 The `$post_type` parameter was added.
return: WP_Post|array|null WP_Post (or array) on success, or null on failure.
param: string       $page_title Page title.
param: string       $output     Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
param: string|array $post_type  Optional. Post type or array of post types. Default 'page'.

get_page_children( $page_id, $pages )   X-Ref
Identify descendants of a given page ID in a list of page objects.

Descendants are identified from the `$pages` array passed to the function. No database queries are performed.

since: 1.5.1
return: array List of page children.
param: int   $page_id Page ID.
param: array $pages   List of page objects from which descendants should be identified.

get_page_hierarchy( &$pages, $page_id = 0 )   X-Ref
Order the pages with children under parents in a flat list.

It uses auxiliary structure to hold parent-children relationships and
runs in O(N) complexity

since: 2.0.0
return: string[] Array of post names keyed by ID and arranged by hierarchy. Children immediately follow their parents.
param: WP_Post[] $pages   Posts array (passed by reference).
param: int       $page_id Optional. Parent page ID. Default 0.

_page_traverse_name( $page_id, &$children, &$result )   X-Ref
Traverse and return all the nested children post names of a root page.

$children contains parent-children relations

since: 2.9.0
param: int      $page_id  Page ID.
param: array    $children Parent-children relations (passed by reference).
param: string[] $result   Array of page names keyed by ID (passed by reference).

get_page_uri( $page = 0 )   X-Ref
Build the URI path for a page.

Sub pages will be in the "directory" under the parent page post name.

since: 1.5.0
since: 4.6.0 The `$page` parameter was made optional.
return: string|false Page URI, false on error.
param: WP_Post|object|int $page Optional. Page ID or WP_Post object. Default is global $post.

get_pages( $args = array()   X-Ref
Retrieve an array of pages (or hierarchical post type items).

since: 1.5.0
return: WP_Post[]|int[]|false Array of pages (or hierarchical post type items). Boolean false if the
param: array|string $args {

is_local_attachment( $url )   X-Ref
Determines whether an attachment URI is local and really an attachment.

For more information on this and similar theme functions, check out
the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
Conditional Tags} article in the Theme Developer Handbook.

since: 2.0.0
return: bool True on success, false on failure.
param: string $url URL to check

wp_insert_attachment( $args, $file = false, $parent = 0, $wp_error = false, $fire_after_hooks = true )   X-Ref
Insert an attachment.

If you set the 'ID' in the $args parameter, it will mean that you are
updating and attempt to update the attachment. You can also set the
attachment name or title by setting the key 'post_name' or 'post_title'.

You can set the dates for the attachment manually by setting the 'post_date'
and 'post_date_gmt' keys' values.

By default, the comments will use the default settings for whether the
comments are allowed. You can close them manually or keep them open by
setting the value for the 'comment_status' key.

since: 2.0.0
since: 4.7.0 Added the `$wp_error` parameter to allow a WP_Error to be returned on failure.
since: 5.6.0 Added the `$fire_after_hooks` parameter.
return: int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
param: string|array $args             Arguments for inserting an attachment.
param: string|false $file             Optional. Filename.
param: int          $parent           Optional. Parent post ID.
param: bool         $wp_error         Optional. Whether to return a WP_Error on failure. Default false.
param: bool         $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true.

wp_delete_attachment( $post_id, $force_delete = false )   X-Ref
Trash or delete an attachment.

When an attachment is permanently deleted, the file will also be removed.
Deletion removes all post meta fields, taxonomy, comments, etc. associated
with the attachment (except the main post).

The attachment is moved to the Trash instead of permanently deleted unless Trash
for media is disabled, item is already in the Trash, or $force_delete is true.

since: 2.0.0
return: WP_Post|false|null Post data on success, false or null on failure.
param: int  $post_id      Attachment ID.
param: bool $force_delete Optional. Whether to bypass Trash and force deletion.

wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file )   X-Ref
Deletes all files that belong to the given attachment.

since: 4.9.7
return: bool True on success, false on failure.
param: int    $post_id      Attachment ID.
param: array  $meta         The attachment's meta data.
param: array  $backup_sizes The meta data for the attachment's backup images.
param: string $file         Absolute path to the attachment's file.

wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false )   X-Ref
Retrieves attachment metadata for attachment ID.

since: 2.1.0
return: array|false {
param: int  $attachment_id Attachment post ID. Defaults to global $post.
param: bool $unfiltered    Optional. If true, filters are not run. Default false.

wp_update_attachment_metadata( $attachment_id, $data )   X-Ref
Updates metadata for an attachment.

since: 2.1.0
return: int|false False if $post is invalid.
param: int   $attachment_id Attachment post ID.
param: array $data          Attachment meta data.

wp_get_attachment_url( $attachment_id = 0 )   X-Ref
Retrieve the URL for an attachment.

since: 2.1.0
return: string|false Attachment URL, otherwise false.
param: int $attachment_id Optional. Attachment post ID. Defaults to global $post.

wp_get_attachment_caption( $post_id = 0 )   X-Ref
Retrieves the caption for an attachment.

since: 4.6.0
return: string|false Attachment caption on success, false on failure.
param: int $post_id Optional. Attachment ID. Default is the ID of the global `$post`.

wp_get_attachment_thumb_file( $post_id = 0 )   X-Ref
Retrieve thumbnail for an attachment.

since: 2.1.0
return: string|false Thumbnail file path on success, false on failure.
param: int $post_id Optional. Attachment ID. Default is the ID of the global `$post`.

wp_get_attachment_thumb_url( $post_id = 0 )   X-Ref
Retrieve URL for an attachment thumbnail.

since: 2.1.0
return: string|false Thumbnail URL on success, false on failure.
param: int $post_id Optional. Attachment ID. Default is the ID of the global `$post`.

wp_attachment_is( $type, $post = null )   X-Ref
Verifies an attachment is of a given type.

since: 4.2.0
return: bool True if one of the accepted types, false otherwise.
param: string      $type Attachment type. Accepts 'image', 'audio', or 'video'.
param: int|WP_Post $post Optional. Attachment ID or object. Default is global $post.

wp_attachment_is_image( $post = null )   X-Ref
Determines whether an attachment is an image.

For more information on this and similar theme functions, check out
the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
Conditional Tags} article in the Theme Developer Handbook.

since: 2.1.0
since: 4.2.0 Modified into wrapper for wp_attachment_is() and
return: bool Whether the attachment is an image.
param: int|WP_Post $post Optional. Attachment ID or object. Default is global $post.

wp_mime_type_icon( $mime = 0 )   X-Ref
Retrieve the icon for a MIME type or attachment.

since: 2.1.0
return: string|false Icon, false otherwise.
param: string|int $mime MIME type or attachment ID.

wp_check_for_changed_slugs( $post_id, $post, $post_before )   X-Ref
Check for changed slugs for published post objects and save the old slug.

The function is used when a post object of any type is updated,
by comparing the current and previous post objects.

If the slug was changed and not already part of the old slugs then it will be
added to the post meta field ('_wp_old_slug') for storing old slugs for that
post.

The most logically usage of this function is redirecting changed post objects, so
that those that linked to an changed post will be redirected to the new post.

since: 2.1.0
param: int     $post_id     Post ID.
param: WP_Post $post        The Post Object
param: WP_Post $post_before The Previous Post Object

wp_check_for_changed_dates( $post_id, $post, $post_before )   X-Ref
Check for changed dates for published post objects and save the old date.

The function is used when a post object of any type is updated,
by comparing the current and previous post objects.

If the date was changed and not already part of the old dates then it will be
added to the post meta field ('_wp_old_date') for storing old dates for that
post.

The most logically usage of this function is redirecting changed post objects, so
that those that linked to an changed post will be redirected to the new post.

since: 4.9.3
param: int     $post_id     Post ID.
param: WP_Post $post        The Post Object
param: WP_Post $post_before The Previous Post Object

get_private_posts_cap_sql( $post_type )   X-Ref
Retrieve the private post SQL based on capability.

This function provides a standardized way to appropriately select on the
post_status of a post type. The function will return a piece of SQL code
that can be added to a WHERE clause; this SQL is constructed to allow all
published posts, and all private posts to which the user has access.

since: 2.2.0
since: 4.3.0 Added the ability to pass an array to `$post_type`.
return: string SQL code that can be added to a where clause.
param: string|array $post_type Single post type or an array of post types. Currently only supports 'post' or 'page'.

get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false )   X-Ref
Retrieve the post SQL based on capability, author, and type.

since: 3.0.0
since: 4.3.0 Introduced the ability to pass an array of post types to `$post_type`.
return: string SQL WHERE code that can be added to a query.
param: string|string[] $post_type   Single post type or an array of post types.
param: bool            $full        Optional. Returns a full WHERE statement instead of just
param: int             $post_author Optional. Query posts having a single author ID. Default null.
param: bool            $public_only Optional. Only return public posts. Skips cap checks for

get_lastpostdate( $timezone = 'server', $post_type = 'any' )   X-Ref
Retrieves the most recent time that a post on the site was published.

The server timezone is the default and is the difference between GMT and
server time. The 'blog' value is the date when the last post was posted.
The 'gmt' is when the last post was posted in GMT formatted date.

since: 0.71
since: 4.4.0 The `$post_type` argument was added.
return: string The date of the last post, or false on failure.
param: string $timezone  Optional. The timezone for the timestamp. Accepts 'server', 'blog', or 'gmt'.
param: string $post_type Optional. The post type to check. Default 'any'.

get_lastpostmodified( $timezone = 'server', $post_type = 'any' )   X-Ref
Get the most recent time that a post on the site was modified.

The server timezone is the default and is the difference between GMT and
server time. The 'blog' value is just when the last post was modified.
The 'gmt' is when the last post was modified in GMT time.

since: 1.2.0
since: 4.4.0 The `$post_type` argument was added.
return: string The timestamp in 'Y-m-d H:i:s' format, or false on failure.
param: string $timezone  Optional. The timezone for the timestamp. See get_lastpostdate()
param: string $post_type Optional. The post type to check. Default 'any'.

_get_last_post_time( $timezone, $field, $post_type = 'any' )   X-Ref
Gets the timestamp of the last time any post was modified or published.

since: 3.1.0
since: 4.4.0 The `$post_type` argument was added.
return: string|false The timestamp in 'Y-m-d H:i:s' format, or false on failure.
param: string $timezone  The timezone for the timestamp. See get_lastpostdate().
param: string $field     Post field to check. Accepts 'date' or 'modified'.
param: string $post_type Optional. The post type to check. Default 'any'.

update_post_cache( &$posts )   X-Ref
Updates posts in cache.

since: 1.5.1
param: WP_Post[] $posts Array of post objects (passed by reference).

clean_post_cache( $post )   X-Ref
Will clean the post in the cache.

Cleaning means delete from the cache of the post. Will call to clean the term
object cache associated with the post ID.

This function not run if $_wp_suspend_cache_invalidation is not empty. See
wp_suspend_cache_invalidation().

since: 2.0.0
param: int|WP_Post $post Post ID or post object to remove from the cache.

update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true )   X-Ref
Call major cache updating functions for list of Post objects.

since: 1.5.0
param: WP_Post[] $posts             Array of Post objects
param: string    $post_type         Optional. Post type. Default 'post'.
param: bool      $update_term_cache Optional. Whether to update the term cache. Default true.
param: bool      $update_meta_cache Optional. Whether to update the meta cache. Default true.

update_postmeta_cache( $post_ids )   X-Ref
Updates metadata cache for list of post IDs.

Performs SQL query to retrieve the metadata for the post IDs and updates the
metadata cache for the posts. Therefore, the functions, which call this
function, do not need to perform SQL queries on their own.

since: 2.1.0
return: array|false An array of metadata on success, false if there is nothing to update.
param: int[] $post_ids Array of post IDs.

clean_attachment_cache( $id, $clean_terms = false )   X-Ref
Will clean the attachment in the cache.

Cleaning means delete from the cache. Optionally will clean the term
object cache associated with the attachment ID.

This function will not run if $_wp_suspend_cache_invalidation is not empty.

since: 3.0.0
param: int  $id          The attachment ID in the cache to clean.
param: bool $clean_terms Optional. Whether to clean terms cache. Default false.

_transition_post_status( $new_status, $old_status, $post )   X-Ref
Hook for managing future post transitions to published.

since: 2.3.0
param: string  $new_status New post status.
param: string  $old_status Previous post status.
param: WP_Post $post       Post object.

_future_post_hook( $deprecated, $post )   X-Ref
Hook used to schedule publication for a post marked for the future.

The $post properties used and must exist are 'ID' and 'post_date_gmt'.

since: 2.3.0
param: int     $deprecated Not used. Can be set to null. Never implemented. Not marked
param: WP_Post $post       Post object.

_publish_post_hook( $post_id )   X-Ref
Hook to schedule pings and enclosures when a post is published.

Uses XMLRPC_REQUEST and WP_IMPORTING constants.

since: 2.3.0
param: int $post_id The ID of the post being published.

wp_get_post_parent_id( $post = null )   X-Ref
Returns the ID of the post's parent.

since: 3.1.0
since: 5.9.0 The `$post` parameter was made optional.
return: int|false Post parent ID (which can be 0 if there is no parent),
param: int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.

wp_check_post_hierarchy_for_loops( $post_parent, $post_ID )   X-Ref
Check the given subset of the post hierarchy for hierarchy loops.

Prevents loops from forming and breaks those that it finds. Attached
to the {@see 'wp_insert_post_parent'} filter.

since: 3.1.0
return: int The new post_parent for the post, 0 otherwise.
param: int $post_parent ID of the parent for the post we're checking.
param: int $post_ID     ID of the post we're checking.

set_post_thumbnail( $post, $thumbnail_id )   X-Ref
Sets the post thumbnail (featured image) for the given post.

since: 3.1.0
return: int|bool True on success, false on failure.
param: int|WP_Post $post         Post ID or post object where thumbnail should be attached.
param: int         $thumbnail_id Thumbnail to attach.

delete_post_thumbnail( $post )   X-Ref
Removes the thumbnail (featured image) from the given post.

since: 3.3.0
return: bool True on success, false on failure.
param: int|WP_Post $post Post ID or post object from which the thumbnail should be removed.

wp_delete_auto_drafts()   X-Ref
Delete auto-drafts for new posts that are > 7 days old.

since: 3.4.0

wp_queue_posts_for_term_meta_lazyload( $posts )   X-Ref
Queues posts for lazy-loading of term meta.

since: 4.5.0
param: array $posts Array of WP_Post objects.

_update_term_count_on_transition_post_status( $new_status, $old_status, $post )   X-Ref
Update the custom taxonomies' term counts when a post's status is changed.

For example, default posts term counts (for custom taxonomies) don't include
private / draft posts.

since: 3.3.0
param: string  $new_status New post status.
param: string  $old_status Old post status.
param: WP_Post $post       Post object.

_prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true )   X-Ref
Adds any posts from the given IDs to the cache that do not already exist in cache.

since: 3.4.0
param: array $ids               ID list.
param: bool  $update_term_cache Optional. Whether to update the term cache. Default true.
param: bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.

wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 )   X-Ref
Adds a suffix if any trashed posts have a given slug.

Store its desired (i.e. current) slug so it can try to reclaim it
if the post is untrashed.

For internal use.

since: 4.5.0
param: string $post_name Post slug.
param: int    $post_ID   Optional. Post ID that should be ignored. Default 0.

wp_add_trashed_suffix_to_post_name_for_post( $post )   X-Ref
Adds a trashed suffix for a given post.

Store its desired (i.e. current) slug so it can try to reclaim it
if the post is untrashed.

For internal use.

since: 4.5.0
return: string New slug for the post.
param: WP_Post $post The post.

_filter_query_attachment_filenames( $clauses )   X-Ref
Filters the SQL clauses of an attachment query to include filenames.

since: 4.7.0
return: string[] The modified array of clauses.
param: string[] $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,

wp_cache_set_posts_last_changed()   X-Ref
Sets the last changed time for the 'posts' cache group.

since: 5.0.0

get_available_post_mime_types( $type = 'attachment' )   X-Ref
Get all available post MIME types for a given post type.

since: 2.5.0
return: mixed
param: string $type

wp_get_original_image_path( $attachment_id, $unfiltered = false )   X-Ref
Retrieves the path to an uploaded image file.

Similar to `get_attached_file()` however some images may have been processed after uploading
to make them suitable for web use. In this case the attached "full" size file is usually replaced
with a scaled down version of the original image. This function always returns the path
to the originally uploaded image file.

since: 5.3.0
since: 5.4.0 Added the `$unfiltered` parameter.
return: string|false Path to the original image file or false if the attachment is not an image.
param: int  $attachment_id Attachment ID.
param: bool $unfiltered Optional. Passed through to `get_attached_file()`. Default false.

wp_get_original_image_url( $attachment_id )   X-Ref
Retrieve the URL to an original attachment image.

Similar to `wp_get_attachment_url()` however some images may have been
processed after uploading. In this case this function returns the URL
to the originally uploaded image file.

since: 5.3.0
return: string|false Attachment image URL, false on error or if the attachment is not an image.
param: int $attachment_id Attachment post ID.

wp_untrash_post_set_previous_status( $new_status, $post_id, $previous_status )   X-Ref
Filter callback which sets the status of an untrashed post to its previous status.

This can be used as a callback on the `wp_untrash_post_status` filter.

since: 5.6.0
return: string The new status of the post.
param: string $new_status      The new status of the post being restored.
param: int    $post_id         The ID of the post being restored.
param: string $previous_status The status of the post at the point where it was trashed.



Generated: Tue Mar 19 01:00:02 2024 Cross-referenced by PHPXref 0.7.1