get_post( int|WP_Post|null $post = null, string $output = OBJECT, string $filter = 'raw' ): WP_Post|array|null
Retrieves post data given a post ID or post object.
Contents
Description
See sanitize_post() for optional $filter values. Also, the parameter $post
, must be given as a variable, since it is passed by reference.
Parameters
-
$post
int|WP_Post|null Optional -
Post ID or post object.
null
,false
,0
and other PHP falsey values return the current global post inside the loop. A numerically valid post ID that points to a non-existent post returnsnull
. Defaults to global $post.Default:
null
-
$output
string Optional -
The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Post object, an associative array, or a numeric array, respectively.
Default:
OBJECT
-
$filter
string Optional -
Type of filter to apply. Accepts
'raw'
,'edit'
,'db'
, or'display'
. Default'raw'
.Default:
'raw'
Return
WP_Post|array|null Type corresponding to $output on success or null on failure.
When $output is OBJECT, a WP_Post
instance is returned.
Source
File: wp-includes/post.php
.
View all references
function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
if ( empty( $post ) && isset( $GLOBALS['post'] ) ) {
$post = $GLOBALS['post'];
}
if ( $post instanceof WP_Post ) {
$_post = $post;
} elseif ( is_object( $post ) ) {
if ( empty( $post->filter ) ) {
$_post = sanitize_post( $post, 'raw' );
$_post = new WP_Post( $_post );
} elseif ( 'raw' === $post->filter ) {
$_post = new WP_Post( $post );
} else {
$_post = WP_Post::get_instance( $post->ID );
}
} else {
$_post = WP_Post::get_instance( $post );
}
if ( ! $_post ) {
return null;
}
$_post = $_post->filter( $filter );
if ( ARRAY_A === $output ) {
return $_post->to_array();
} elseif ( ARRAY_N === $output ) {
return array_values( $_post->to_array() );
}
return $_post;
}
Related
Uses
Uses | Description |
---|---|
WP_Post::__construct() wp-includes/class-wp-post.php |
Constructor. |
WP_Post::get_instance() wp-includes/class-wp-post.php |
Retrieve WP_Post instance. |
sanitize_post() wp-includes/post.php |
Sanitizes every post field. |
Used By
Used By | Description |
---|---|
wp_get_latest_revision_id_and_total_count() wp-includes/revision.php |
Returns the latest revision ID and count of revisions for a post. |
wp_get_post_revisions_url() wp-includes/revision.php |
Returns the url for viewing and potentially restoring revisions of a given post. |
WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles() wp-includes/class-wp-theme-json-resolver.php |
Returns the custom post type that contains the user’s origin config for the active theme or a void array if none are found. |
WP_REST_Menu_Items_Controller::create_item() wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php |
Creates a single post. |
WP_REST_Menu_Items_Controller::update_item() wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php |
Updates a single nav menu item. |
WP_REST_Menu_Items_Controller::delete_item() wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php |
Deletes a single menu item. |
WP_REST_Menu_Items_Controller::prepare_item_for_database() wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php |
Prepares a single post for create or update. |
WP_REST_Global_Styles_Controller::get_post() wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php |
Get the post, if the ID is valid. |
WP_REST_Global_Styles_Controller::update_item() wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php |
Updates a single global style config. |
WP_REST_Global_Styles_Controller::prepare_item_for_database() wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php |
Prepares a single global styles config for update. |
wp_set_unique_slug_on_create_template_part() wp-includes/theme-templates.php |
Sets a custom slug when creating auto-draft template parts. |
_resolve_template_for_new_post() wp-includes/block-template.php |
Sets the current WP_Query to return auto-draft posts. |
WP_REST_Templates_Controller::update_item() wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php |
Updates a single template. |
WP_REST_Templates_Controller::create_item() wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php |
Creates a single template. |
get_adjacent_image_link() wp-includes/media.php |
Gets the next or previous image link that has the same post parent. |
WP_REST_Posts_Controller::check_password_required() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Overrides the result of the post password check for REST requested posts. |
wp_force_plain_post_permalink() wp-includes/link-template.php |
Determine whether post should always use a plain permalink structure. |
is_post_publicly_viewable() wp-includes/post.php |
Determines whether a post is publicly viewable. |
get_post_parent() wp-includes/post-template.php |
Retrieves the parent post object for the given post. |
wp_after_insert_post() wp-includes/post.php |
Fires actions after a post, its terms and meta data has been saved. |
WP_REST_Attachments_Controller::edit_media_item() wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php |
Applies edits to a media item and creates a new attachment record. |
rest_get_route_for_post() wp-includes/rest-api.php |
Gets the REST API route for a post. |
wp_get_user_request() wp-includes/user.php |
Returns the user request object for the specified request ID. |
WP_REST_Attachments_Controller::insert_attachment() wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php |
Inserts the attachment post in the database. Does not update the attachment meta. |
WP_REST_Attachments_Controller::post_process_item() wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php |
Performs post processing on an attachment. |
get_post_datetime() wp-includes/general-template.php |
Retrieves post published or modified time as a |
wp_ajax_media_create_image_subsizes() wp-admin/includes/ajax-actions.php |
Ajax handler for creating missing image sub-sizes for just uploaded images. |
WP_Query::generate_postdata() wp-includes/class-wp-query.php |
Generate post data. |
WP_REST_Autosaves_Controller::create_item() wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php |
Creates, updates or deletes an autosave revision. |
WP_REST_Autosaves_Controller::create_post_autosave() wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php |
Creates autosave for the specified post. |
WP_REST_Block_Renderer_Controller::get_item_permissions_check() wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php |
Checks if a given request has access to read blocks. |
WP_REST_Block_Renderer_Controller::get_item() wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php |
Returns block output from block’s registered render_callback. |
WP_REST_Post_Search_Handler::prepare_item() wp-includes/rest-api/search/class-wp-rest-post-search-handler.php |
Prepares the search result for a given ID. |
WP_REST_Post_Search_Handler::prepare_item_links() wp-includes/rest-api/search/class-wp-rest-post-search-handler.php |
Prepares links for the search result of a given ID. |
has_blocks() wp-includes/blocks.php |
Determines whether a post or content string has blocks. |
has_block() wp-includes/blocks.php |
Determines whether a $post or a string contains a specific block type. |
use_block_editor_for_post() wp-includes/post.php |
Returns whether the post can be edited in the block editor. |
WP_Privacy_Policy_Content::notice() wp-admin/includes/class-wp-privacy-policy-content.php |
Add a notice with a link to the guide when editing the privacy policy page. |
_wp_privacy_resend_request() wp-admin/includes/privacy-tools.php |
Resend an existing request and return the result. |
WP_Customize_Manager::trash_changeset_post() wp-includes/class-wp-customize-manager.php |
Trashes or deletes a changeset post. |
WP_REST_Posts_Controller::check_template() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Checks whether the template is valid for the given post. |
WP_REST_Revisions_Controller::get_revision() wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php |
Get the revision, if the ID is valid. |
WP_REST_Revisions_Controller::get_parent() wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php |
Get the parent post, if the ID is valid. |
WP_REST_Posts_Controller::get_post() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Gets the post, if the ID is valid. |
WP_REST_Comments_Controller::get_comment() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php |
Get the comment, if the ID is valid. |
_wp_delete_customize_changeset_dependent_auto_drafts() wp-includes/nav-menu.php |
Deletes auto-draft posts associated with the supplied changeset. |
WP_Widget_Media_Audio::render_media() wp-includes/widgets/class-wp-widget-media-audio.php |
Render the media on the frontend. |
WP_Widget_Media_Video::render_media() wp-includes/widgets/class-wp-widget-media-video.php |
Render the media on the frontend. |
WP_Widget_Media::display_media_state() wp-includes/widgets/class-wp-widget-media.php |
Filters the default media display states for items in the Media list table. |
WP_Widget_Media::is_attachment_with_mime_type() wp-includes/widgets/class-wp-widget-media.php |
Determine if the supplied attachment is for a valid attachment post with the specified MIME type. |
WP_Widget_Media_Image::render_media() wp-includes/widgets/class-wp-widget-media-image.php |
Render the media on the frontend. |
WP_Customize_Manager::_publish_changeset_values() wp-includes/class-wp-customize-manager.php |
Publishes the values of a changeset. |
WP_Customize_Manager::save_changeset_post() wp-includes/class-wp-customize-manager.php |
Saves the post for the loaded changeset. |
WP_Customize_Manager::import_theme_starter_content() wp-includes/class-wp-customize-manager.php |
Imports theme starter content into the customized state. |
WP_Customize_Manager::get_changeset_post_data() wp-includes/class-wp-customize-manager.php |
Gets the data stored in a changeset post. |
wp_update_custom_css_post() wp-includes/theme.php |
Updates the |
wp_get_custom_css_post() wp-includes/theme.php |
Fetches the |
WP_REST_Attachments_Controller::create_item() wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php |
Creates a single attachment. |
WP_REST_Attachments_Controller::update_item() wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php |
Updates a single attachment. |
WP_REST_Terms_Controller::get_items_permissions_check() wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php |
Checks if a request has access to read terms in the specified taxonomy. |
WP_REST_Posts_Controller::check_read_permission() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Checks if a post can be read. |
WP_REST_Posts_Controller::handle_template() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Sets the template for a post. |
WP_REST_Posts_Controller::prepare_item_for_database() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Prepares a single post for create or update. |
WP_REST_Posts_Controller::create_item() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Creates a single post. |
WP_REST_Posts_Controller::update_item() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Updates a single post. |
WP_REST_Posts_Controller::delete_item() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php |
Deletes a single post. |
WP_REST_Comments_Controller::check_read_permission() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php |
Checks if the comment can be read. |
WP_REST_Comments_Controller::prepare_links() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php |
Prepares links for the request. |
WP_REST_Comments_Controller::update_item() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php |
Updates a comment. |
WP_REST_Comments_Controller::get_item_permissions_check() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php |
Checks if a given request has access to read the comment. |
WP_REST_Comments_Controller::create_item_permissions_check() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php |
Checks if a given request has access to create a comment. |
WP_REST_Comments_Controller::get_items_permissions_check() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php |
Checks if a given request has access to read comments. |
WP_Customize_Nav_Menus::sanitize_nav_menus_created_posts() wp-includes/class-wp-customize-nav-menus.php |
Sanitizes post IDs for posts created for nav menu items to be published. |
WP_Customize_Nav_Menus::insert_auto_draft_post() wp-includes/class-wp-customize-nav-menus.php |
Adds a new |
WP_Customize_Nav_Menu_Item_Setting::get_original_title() wp-includes/customize/class-wp-customize-nav-menu-item-setting.php |
Get original title. |
_wp_preview_post_thumbnail_filter() wp-includes/revision.php |
Filters post thumbnail lookup to set the post thumbnail. |
wp_get_canonical_url() wp-includes/link-template.php |
Returns the canonical URL for a post. |
wp_get_attachment_caption() wp-includes/post.php |
Retrieves the caption for an attachment. |
_wp_post_revision_data() wp-includes/revision.php |
Returns a post array ready to be inserted into the posts table as a post revision. |
wp_add_trashed_suffix_to_post_name_for_post() wp-includes/post.php |
Adds a trashed suffix for a given post. |
get_post_embed_url() wp-includes/embed.php |
Retrieves the URL to embed a specific post in an iframe. |
get_post_embed_html() wp-includes/embed.php |
Retrieves the embed code for a specific post. |
get_oembed_response_data() wp-includes/embed.php |
Retrieves the oEmbed response data for a given post. |
WP_Customize_Manager::customize_pane_settings() wp-includes/class-wp-customize-manager.php |
Prints JavaScript settings for parent window. |
WP_Comment::__isset() wp-includes/class-wp-comment.php |
Check whether a non-public property is set. |
WP_Comment::__get() wp-includes/class-wp-comment.php |
Magic getter. |
wp_handle_comment_submission() wp-includes/comment.php |
Handles the submission of a comment, usually posted to wp-comments-post.php via a comment form. |
get_preview_post_link() wp-includes/link-template.php |
Retrieves the URL used for the post preview. |
WP_Customize_Nav_Menu_Item_Setting::value() wp-includes/customize/class-wp-customize-nav-menu-item-setting.php |
Get the instance data for a given nav_menu_item setting. |
WP_Customize_Nav_Menus::load_available_items_query() wp-includes/class-wp-customize-nav-menus.php |
Performs the post_type and taxonomy queries for loading available menu items. |
WP_Posts_List_Table::column_title() wp-admin/includes/class-wp-posts-list-table.php |
Handles the title column output. |
WP_Site_Icon::create_attachment_object() wp-admin/includes/class-wp-site-icon.php |
Creates an attachment ‘object’. |
wp_ajax_crop_image() wp-admin/includes/ajax-actions.php |
Ajax handler for cropping an image. |
WP_Media_List_Table::column_parent() wp-admin/includes/class-wp-media-list-table.php |
Handles the parent column output. |
wp_attachment_is() wp-includes/post.php |
Verifies an attachment is of a given type. |
WP_Query::setup_postdata() wp-includes/class-wp-query.php |
Set up global post data. |
_update_posts_count_on_delete() wp-includes/ms-blogs.php |
Handler for updating the current site’s posts count when a post is deleted. |
wp_ajax_parse_embed() wp-admin/includes/ajax-actions.php |
Apply [embed] Ajax handlers to a string. |
wp_ajax_parse_media_shortcode() wp-admin/includes/ajax-actions.php | |
File_Upload_Upgrader::__construct() wp-admin/includes/class-file-upload-upgrader.php |
Construct the upgrader for a form. |
WP_Screen::get() wp-admin/includes/class-wp-screen.php |
Fetches a screen object. |
wxr_post_taxonomy() wp-admin/includes/export.php |
Outputs list of taxonomy terms, in XML tag format, associated with a post. |
get_post_to_edit() wp-admin/includes/deprecated.php |
Gets an existing post and format it for editing. |
stream_preview_image() wp-admin/includes/image-edit.php |
Streams image in post to browser, along with enqueued changes in |
wp_save_image() wp-admin/includes/image-edit.php |
Saves image to post, along with enqueued changes in |
wp_generate_attachment_metadata() wp-admin/includes/image.php |
Generates attachment meta data and create image sub-sizes for images. |
wp_dashboard_quick_press() wp-admin/includes/dashboard.php |
The Quick Draft widget display and creation of drafts. |
the_post_password() wp-admin/includes/template.php |
Displays the post password. |
meta_form() wp-admin/includes/template.php |
Prints the form in the Custom Fields meta box. |
touch_time() wp-admin/includes/template.php |
Prints out HTML form date elements for editing post or comment publish date. |
parent_dropdown() wp-admin/includes/template.php |
Prints out option HTML elements for the page parents drop-down. |
wp_popular_terms_checklist() wp-admin/includes/template.php |
Retrieves a list of the most popular terms from the specified taxonomy. |
media_upload_flash_bypass() wp-admin/includes/media.php |
Displays the multi-file uploader message. |
attachment_submitbox_metadata() wp-admin/includes/media.php |
Displays non-editable attachment metadata in the publish meta box. |
image_media_send_to_editor() wp-admin/includes/media.php |
Retrieves the media element HTML to send to the editor. |
get_attachment_fields_to_edit() wp-admin/includes/media.php |
Retrieves the attachment fields to edit form fields. |
get_media_items() wp-admin/includes/media.php |
Retrieves HTML for media items of post gallery. |
get_media_item() wp-admin/includes/media.php |
Retrieves HTML form for modifying the image attachment. |
get_compat_media_markup() wp-admin/includes/media.php | |
media_upload_form_handler() wp-admin/includes/media.php |
Handles form submissions for the legacy media uploader. |
media_handle_upload() wp-admin/includes/media.php |
Saves a file submitted from a POST request and create an attachment post for it. |
media_handle_sideload() wp-admin/includes/media.php |
Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload() . |
media_buttons() wp-admin/includes/media.php |
Adds the media button to the editor. |
get_sample_permalink_html() wp-admin/includes/post.php |
Returns the HTML of the sample permalink slug editor. |
_wp_post_thumbnail_html() wp-admin/includes/post.php |
Returns HTML for the post thumbnail meta box. |
wp_check_post_lock() wp-admin/includes/post.php |
Determines whether the post is currently being edited by another user. |
wp_set_post_lock() wp-admin/includes/post.php |
Marks the post as currently being edited by the current user. |
_admin_notice_post_locked() wp-admin/includes/post.php |
Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post. |
wp_create_post_autosave() wp-admin/includes/post.php |
Creates autosave data for the specified post from |
post_preview() wp-admin/includes/post.php |
Saves a draft or manually autosaves for the purpose of showing a post preview. |
wp_autosave() wp-admin/includes/post.php |
Saves a post submitted with XHR. |
_fix_attachment_links() wp-admin/includes/post.php |
Replaces hrefs of attachment anchors with up-to-date permalinks. |
get_sample_permalink() wp-admin/includes/post.php |
Returns a sample permalink based on the post name. |
edit_post() wp-admin/includes/post.php |
Updates an existing post with values provided in |
bulk_edit_posts() wp-admin/includes/post.php |
Processes the post data for the bulk editing of posts. |
get_default_post_to_edit() wp-admin/includes/post.php |
Returns default post information to use when populating the “Write Post” form. |
wp_ajax_save_attachment_order() wp-admin/includes/ajax-actions.php |
Ajax handler for saving the attachment order. |
wp_ajax_send_attachment_to_editor() wp-admin/includes/ajax-actions.php |
Ajax handler for sending an attachment to the editor. |
wp_ajax_send_link_to_editor() wp-admin/includes/ajax-actions.php |
Ajax handler for sending a link to the editor. |
wp_ajax_get_revision_diffs() wp-admin/includes/ajax-actions.php |
Ajax handler for getting revision diffs. |
wp_ajax_wp_fullscreen_save_post() wp-admin/includes/ajax-actions.php |
Ajax handler for saving posts from the fullscreen editor. |
wp_ajax_wp_remove_post_lock() wp-admin/includes/ajax-actions.php |
Ajax handler for removing a post lock. |
wp_ajax_get_attachment() wp-admin/includes/ajax-actions.php |
Ajax handler for getting an attachment. |
wp_ajax_save_attachment() wp-admin/includes/ajax-actions.php |
Ajax handler for updating attachment attributes. |
wp_ajax_save_attachment_compat() wp-admin/includes/ajax-actions.php |
Ajax handler for saving backward compatible attachment attributes. |
wp_ajax_add_menu_item() wp-admin/includes/ajax-actions.php |
Ajax handler for adding a menu item. |
wp_ajax_add_meta() wp-admin/includes/ajax-actions.php |
Ajax handler for adding meta. |
wp_ajax_inline_save() wp-admin/includes/ajax-actions.php |
Ajax handler for Quick Edit saving a post from a list table. |
wp_ajax_delete_post() wp-admin/includes/ajax-actions.php |
Ajax handler for deleting a post. |
wp_ajax_trash_post() wp-admin/includes/ajax-actions.php |
Ajax handler for sending a post to the Trash. |
wp_ajax_delete_page() wp-admin/includes/ajax-actions.php |
Ajax handler to delete a page. |
wp_ajax_replyto_comment() wp-admin/includes/ajax-actions.php |
Ajax handler for replying to a comment. |
wp_get_revision_ui_diff() wp-admin/includes/revision.php |
Get the revision UI diff. |
wp_prepare_revisions_for_js() wp-admin/includes/revision.php |
Prepare revisions for JavaScript. |
WP_Comments_List_Table::column_response() wp-admin/includes/class-wp-comments-list-table.php | |
WP_Comments_List_Table::single_row() wp-admin/includes/class-wp-comments-list-table.php | |
Walker_Nav_Menu_Edit::start_el() wp-admin/includes/class-walker-nav-menu-edit.php |
Start the element output. |
_wp_ajax_menu_quick_search() wp-admin/includes/nav-menu.php |
Prints the appropriate response to a menu quick search. |
wp_nav_menu_item_post_type_meta_box() wp-admin/includes/nav-menu.php |
Displays a meta box for a post type menu item. |
WP_Posts_List_Table::single_row() wp-admin/includes/class-wp-posts-list-table.php | |
WP_Posts_List_Table::_page_rows() wp-admin/includes/class-wp-posts-list-table.php |
Given a top level page ID, display the nested hierarchy of sub-pages together with paging support |
Custom_Image_Header::create_attachment_object() wp-admin/includes/class-custom-image-header.php |
Create an attachment ‘object’. |
author_can() wp-includes/capabilities.php |
Returns whether the author of the supplied post has the specified capability. |
map_meta_cap() wp-includes/capabilities.php |
Maps a capability to the primitive capabilities required of the given user to satisfy the capability being checked. |
WP_Customize_Manager::save() wp-includes/class-wp-customize-manager.php |
Handles customize_save WP Ajax request to save/update a changeset. |
has_term() wp-includes/category-template.php |
Checks if the current post has any of given terms. |
get_the_terms() wp-includes/category-template.php |
Retrieves the terms of the taxonomy that are attached to the post. |
wp_trim_excerpt() wp-includes/formatting.php |
Generates an excerpt from the content, if needed. |
wp_notify_postauthor() wp-includes/pluggable.php |
Notifies an author (and/or others) of a comment/trackback/pingback on a post. |
wp_notify_moderator() wp-includes/pluggable.php |
Notifies the moderator of the site about a new comment that is awaiting approval. |
feed_links_extra() wp-includes/general-template.php |
Displays the links to the extra feeds such as category feeds. |
get_the_modified_date() wp-includes/general-template.php |
Retrieves the date on which the post was last modified. |
get_the_time() wp-includes/general-template.php |
Retrieves the time at which the post was written. |
get_post_time() wp-includes/general-template.php |
Retrieves the time at which the post was written. |
get_the_modified_time() wp-includes/general-template.php |
Retrieves the time at which the post was last modified. |
get_post_modified_time() wp-includes/general-template.php |
Retrieves the time at which the post was last modified. |
the_weekday() wp-includes/general-template.php |
Displays the weekday on which the post was written. |
the_weekday_date() wp-includes/general-template.php |
Displays the weekday on which the post was written. |
the_date_xml() wp-includes/general-template.php |
Outputs the date in iso8601 format for xml files. |
get_the_date() wp-includes/general-template.php |
Retrieves the date on which the post was written. |
wp_get_single_post() wp-includes/deprecated.php |
Retrieve a single post, based on post ID. |
get_parent_post_rel_link() wp-includes/deprecated.php |
Get parent post relational link. |
get_the_attachment_link() wp-includes/deprecated.php |
Retrieve HTML content of attachment image with link. |
get_attachment_icon_src() wp-includes/deprecated.php |
Retrieve icon URL and Path. |
get_attachment_icon() wp-includes/deprecated.php |
Retrieve HTML content of icon attachment image element. |
get_attachment_innerHTML() wp-includes/deprecated.php |
Retrieve HTML content of image element. |
user_can_edit_post() wp-includes/deprecated.php |
Whether user can edit a post. |
get_postdata() wp-includes/deprecated.php |
Retrieves all post data for a given post. |
start_wp() wp-includes/deprecated.php |
Sets up the WordPress Loop. |
WP_Query::get_queried_object() wp-includes/class-wp-query.php |
Retrieves the currently queried object. |
WP_Query::get_posts() wp-includes/class-wp-query.php |
Retrieves an array of posts based on query variables. |
wp_scheduled_delete() wp-includes/functions.php |
Permanently deletes comments or posts of any type that have held a status of ‘trash’ for the number of days defined in EMPTY_TRASH_DAYS. |
do_enclose() wp-includes/functions.php |
Checks content for video and audio links to add as enclosures. |
WP_Embed::cache_oembed() wp-includes/class-wp-embed.php |
Triggers a caching of all oEmbed results. |
WP_Embed::maybe_run_ajax_cache() wp-includes/class-wp-embed.php |
If a post/page was saved, then output JavaScript to make an Ajax request that will call WP_Embed::cache_oembed(). |
WP_Embed::shortcode() wp-includes/class-wp-embed.php |
The do_shortcode() callback function. |
get_the_taxonomies() wp-includes/taxonomy.php |
Retrieves all taxonomies associated with a post. |
get_post_taxonomies() wp-includes/taxonomy.php |
Retrieves all taxonomy names for the given post. |
wp_get_shortlink() wp-includes/link-template.php |
Returns a shortlink for a post, page, attachment, or site. |
the_shortlink() wp-includes/link-template.php |
Displays the shortlink for a post. |
get_adjacent_post_link() wp-includes/link-template.php |
Retrieves the adjacent post link. |
get_adjacent_post() wp-includes/link-template.php |
Retrieves the adjacent post. |
get_adjacent_post_rel_link() wp-includes/link-template.php |
Retrieves the adjacent post relational link. |
get_boundary_post() wp-includes/link-template.php |
Retrieves the boundary post. |
get_edit_post_link() wp-includes/link-template.php |
Retrieves the edit post link for post. |
edit_post_link() wp-includes/link-template.php |
Displays the edit post link for post. |
get_delete_post_link() wp-includes/link-template.php |
Retrieves the delete posts link for post. |
get_post_comments_feed_link() wp-includes/link-template.php |
Retrieves the permalink for the post comments feed. |
permalink_anchor() wp-includes/link-template.php |
Displays the permalink anchor for the current post. |
get_permalink() wp-includes/link-template.php |
Retrieves the full permalink for the current post or post ID. |
get_post_permalink() wp-includes/link-template.php |
Retrieves the permalink for a post of a custom post type. |
get_page_link() wp-includes/link-template.php |
Retrieves the permalink for the current page or page ID. |
_get_page_link() wp-includes/link-template.php |
Retrieves the page permalink. |
get_attachment_link() wp-includes/link-template.php |
Retrieves the permalink for an attachment. |
wp_admin_bar_edit_menu() wp-includes/admin-bar.php |
Provides an edit link for posts and terms. |
get_post_thumbnail_id() wp-includes/post-thumbnail-template.php |
Retrieves the post thumbnail ID. |
get_the_post_thumbnail() wp-includes/post-thumbnail-template.php |
Retrieves the post thumbnail. |
Walker_Page::start_el() wp-includes/class-walker-page.php |
Outputs the beginning of the current element in the tree. |
wp_get_attachment_link() wp-includes/post-template.php |
Retrieves an attachment page link using an image or icon, if possible. |
prepend_attachment() wp-includes/post-template.php |
Wraps attachment in paragraph tag before content. |
get_the_password_form() wp-includes/post-template.php |
Retrieves protected post password form content. |
get_page_template_slug() wp-includes/post-template.php |
Gets the specific template filename for a given post. |
wp_post_revision_title() wp-includes/post-template.php |
Retrieves formatted date timestamp of a revision (linked to that revisions’s page). |
wp_post_revision_title_expanded() wp-includes/post-template.php |
Retrieves formatted date timestamp of a revision (linked to that revisions’s page). |
wp_list_post_revisions() wp-includes/post-template.php |
Displays a list of a post’s revisions. |
post_password_required() wp-includes/post-template.php |
Determines whether the post requires password and whether a correct password has been provided. |
_wp_link_page() wp-includes/post-template.php |
Helper function for wp_link_pages() . |
get_the_guid() wp-includes/post-template.php |
Retrieves the Post Global Unique Identifier (guid). |
get_the_content() wp-includes/post-template.php |
Retrieves the post content. |
get_the_excerpt() wp-includes/post-template.php |
Retrieves the post excerpt. |
has_excerpt() wp-includes/post-template.php |
Determines whether the post has a custom excerpt. |
get_post_class() wp-includes/post-template.php |
Retrieves an array of the class names for the post container element. |
get_body_class() wp-includes/post-template.php |
Retrieves an array of the class names for the body element. |
get_the_ID() wp-includes/post-template.php |
Retrieves the ID of the current item in the WordPress Loop. |
the_title_attribute() wp-includes/post-template.php |
Sanitizes the current title when retrieving or displaying. |
get_the_title() wp-includes/post-template.php |
Retrieves the post title. |
the_guid() wp-includes/post-template.php |
Displays the Post Global Unique Identifier (guid). |
get_post_galleries() wp-includes/media.php |
Retrieves galleries from the passed post’s content. |
wp_prepare_attachment_for_js() wp-includes/media.php |
Prepares an attachment post object for JS, where it is expected to be JSON-encoded and fit into an Attachment model. |
wp_enqueue_media() wp-includes/media.php |
Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. |
get_attached_media() wp-includes/media.php |
Retrieves media attached to the passed post. |
wp_video_shortcode() wp-includes/media.php |
Builds the Video shortcode output. |
get_attachment_taxonomies() wp-includes/media.php |
Retrieves taxonomies attached to given the attachment. |
gallery_shortcode() wp-includes/media.php |
Builds the Gallery shortcode output. |
wp_playlist_shortcode() wp-includes/media.php |
Builds the Playlist shortcode output. |
wp_audio_shortcode() wp-includes/media.php |
Builds the Audio shortcode output. |
wp_get_attachment_image() wp-includes/media.php |
Gets an HTML img element representing an image attachment. |
clean_post_cache() wp-includes/post.php |
Will clean the post in the cache. |
wp_get_post_parent_id() wp-includes/post.php |
Returns the ID of the post’s parent. |
set_post_thumbnail() wp-includes/post.php |
Sets the post thumbnail (featured image) for the given post. |
delete_post_thumbnail() wp-includes/post.php |
Removes the thumbnail (featured image) from the given post. |
wp_mime_type_icon() wp-includes/post.php |
Retrieves the icon for a MIME type or attachment. |
wp_delete_attachment() wp-includes/post.php |
Trashes or deletes an attachment. |
wp_get_attachment_metadata() wp-includes/post.php |
Retrieves attachment metadata for attachment ID. |
wp_update_attachment_metadata() wp-includes/post.php |
Updates metadata for an attachment. |
wp_get_attachment_url() wp-includes/post.php |
Retrieves the URL for an attachment. |
wp_get_attachment_thumb_file() wp-includes/deprecated.php |
Retrieves thumbnail for an attachment. |
get_pung() wp-includes/post.php |
Retrieves URLs already pinged for a post. |
get_to_ping() wp-includes/post.php |
Retrieves URLs that need to be pinged. |
trackback_url_list() wp-includes/post.php |
Does trackbacks for a list of URLs. |
get_page() wp-includes/post.php |
Retrieves page data given a page ID or page object. |
get_page_by_path() wp-includes/post.php |
Retrieves a page given its path. |
get_page_by_title() wp-includes/post.php |
Retrieves a page given its title. |
get_page_uri() wp-includes/post.php |
Builds the URI path for a page. |
is_local_attachment() wp-includes/post.php |
Determines whether an attachment URI is local and really an attachment. |
wp_publish_post() wp-includes/post.php |
Publishes a post by transitioning the post status. |
check_and_publish_future_post() wp-includes/post.php |
Publishes future post and make sure post ID has future post status. |
wp_unique_post_slug() wp-includes/post.php |
Computes a unique slug for the post, when given the desired slug and some post details. |
add_ping() wp-includes/post.php |
Adds a URL to those already pinged. |
wp_untrash_post_comments() wp-includes/post.php |
Restores comments for a post from the Trash. |
wp_insert_post() wp-includes/post.php |
Inserts or update a post. |
wp_update_post() wp-includes/post.php |
Updates a post with new post data. |
wp_delete_post() wp-includes/post.php |
Trashes or deletes a post or page. |
_reset_front_page_settings_for_post() wp-includes/post.php |
Resets the page_on_front, show_on_front, and page_for_post settings when a linked page is deleted or trashed. |
wp_trash_post() wp-includes/post.php |
Moves a post or page to the Trash |
wp_untrash_post() wp-includes/post.php |
Restores a post from the Trash. |
wp_trash_post_comments() wp-includes/post.php |
Moves comments for a post to the Trash. |
get_post_ancestors() wp-includes/post.php |
Retrieves the IDs of the ancestors of a post. |
get_post_field() wp-includes/post.php |
Retrieves data from a post field based on Post ID. |
get_post_mime_type() wp-includes/post.php |
Retrieves the mime type of an attachment based on the ID. |
get_post_status() wp-includes/post.php |
Retrieves the post status based on the post ID. |
get_post_type() wp-includes/post.php |
Retrieves the post type of the current post or of a given post. |
update_attached_file() wp-includes/post.php |
Updates attachment file path based on attachment ID. |
url_to_postid() wp-includes/rewrite.php |
Examines a URL and try to determine the post ID it represents. |
redirect_canonical() wp-includes/canonical.php |
Redirects incoming links to the proper URL based on the site url. |
_wp_put_post_revision() wp-includes/revision.php |
Inserts post data into the posts table as a post revision. |
wp_get_post_revision() wp-includes/revision.php |
Gets a post revision. |
wp_get_post_revisions() wp-includes/revision.php |
Returns all revisions of specified post. |
_wp_preview_terms_filter() wp-includes/revision.php |
Filters terms lookup to set the post format. |
_wp_post_revision_fields() wp-includes/revision.php |
Determines which fields of posts are to be saved in revisions. |
wp_save_post_revision() wp-includes/revision.php |
Creates a revision for the current version of a post. |
wp_get_post_autosave() wp-includes/revision.php |
Retrieves the autosaved data of the specified post. |
get_blog_post() wp-includes/ms-functions.php |
Gets a blog post from any site on the network. |
get_post_format() wp-includes/post-formats.php |
Retrieve the format slug for a post |
set_post_format() wp-includes/post-formats.php |
Assign a format to a post |
get_the_author_posts() wp-includes/author-template.php |
Retrieves the number of posts by the author of the current post. |
get_the_modified_author() wp-includes/author-template.php |
Retrieves the author who last edited the current post. |
_update_blog_date_on_post_delete() wp-includes/ms-blogs.php |
Handler for updating the current site’s last updated date when a published post is deleted. |
wp_setup_nav_menu_item() wp-includes/nav-menu.php |
Decorates a menu item object with the shared navigation menu item properties. |
wp_update_nav_menu_item() wp-includes/nav-menu.php |
Saves the properties of a menu item or create a new one. |
wp_xmlrpc_server::mt_getPostCategories() wp-includes/class-wp-xmlrpc-server.php |
Retrieve post categories. |
wp_xmlrpc_server::mt_setPostCategories() wp-includes/class-wp-xmlrpc-server.php |
Sets categories for a post. |
wp_xmlrpc_server::mt_getTrackbackPings() wp-includes/class-wp-xmlrpc-server.php |
Retrieve trackbacks sent to a given post. |
wp_xmlrpc_server::mt_publishPost() wp-includes/class-wp-xmlrpc-server.php |
Sets a post’s publish status to ‘publish’. |
wp_xmlrpc_server::pingback_ping() wp-includes/class-wp-xmlrpc-server.php |
Retrieves a pingback and registers it. |
wp_xmlrpc_server::pingback_extensions_getPingbacks() wp-includes/class-wp-xmlrpc-server.php |
Retrieve array of URLs that pingbacked the given URL. |
wp_xmlrpc_server::mw_editPost() wp-includes/class-wp-xmlrpc-server.php |
Edit a post. |
wp_xmlrpc_server::mw_getPost() wp-includes/class-wp-xmlrpc-server.php |
Retrieve post. |
wp_xmlrpc_server::mw_newMediaObject() wp-includes/class-wp-xmlrpc-server.php |
Uploads a file, following your settings. |
wp_xmlrpc_server::blogger_getPost() wp-includes/class-wp-xmlrpc-server.php |
Retrieve post. |
wp_xmlrpc_server::blogger_editPost() wp-includes/class-wp-xmlrpc-server.php |
Edit a post. |
wp_xmlrpc_server::blogger_deletePost() wp-includes/class-wp-xmlrpc-server.php |
Remove a post. |
wp_xmlrpc_server::wp_getMediaItem() wp-includes/class-wp-xmlrpc-server.php |
Retrieve a media item by ID |
wp_xmlrpc_server::wp_getRevisions() wp-includes/class-wp-xmlrpc-server.php |
Retrieve revisions for a specific post. |
wp_xmlrpc_server::wp_restoreRevision() wp-includes/class-wp-xmlrpc-server.php |
Restore a post revision |
wp_xmlrpc_server::wp_newComment() wp-includes/class-wp-xmlrpc-server.php |
Create new comment. |
wp_xmlrpc_server::wp_getCommentCount() wp-includes/class-wp-xmlrpc-server.php |
Retrieve comment count. |
wp_xmlrpc_server::wp_deletePage() wp-includes/class-wp-xmlrpc-server.php |
Delete page. |
wp_xmlrpc_server::wp_editPage() wp-includes/class-wp-xmlrpc-server.php |
Edit page. |
wp_xmlrpc_server::wp_getPage() wp-includes/class-wp-xmlrpc-server.php |
Retrieve page. |
wp_xmlrpc_server::_prepare_page() wp-includes/class-wp-xmlrpc-server.php |
Prepares page data for return in an XML-RPC object. |
wp_xmlrpc_server::_insert_post() wp-includes/class-wp-xmlrpc-server.php |
Helper method for wp_newPost() and wp_editPost(), containing shared logic. |
wp_xmlrpc_server::wp_editPost() wp-includes/class-wp-xmlrpc-server.php |
Edit a post for any registered post type. |
wp_xmlrpc_server::wp_deletePost() wp-includes/class-wp-xmlrpc-server.php |
Delete a post for any registered post type. |
wp_xmlrpc_server::wp_getPost() wp-includes/class-wp-xmlrpc-server.php |
Retrieve a post. |
wp_xmlrpc_server::_prepare_post() wp-includes/class-wp-xmlrpc-server.php |
Prepares post data for return in an XML-RPC object. |
WP_Customize_Control::render_content() wp-includes/class-wp-customize-control.php |
Render the control’s content. |
get_post_reply_link() wp-includes/comment-template.php |
Retrieves HTML content for reply to post link. |
comment_form() wp-includes/comment-template.php |
Outputs a complete commenting form for use within a template. |
comments_open() wp-includes/comment-template.php |
Determines whether the current post is open for comments. |
pings_open() wp-includes/comment-template.php |
Determines whether the current post is open for pings. |
wp_comment_form_unfiltered_html_nonce() wp-includes/comment-template.php |
Displays form token for unfiltered comments. |
get_comment_reply_link() wp-includes/comment-template.php |
Retrieves HTML content for reply to comment link. |
get_comments_number() wp-includes/comment-template.php |
Retrieves the amount of comments a post has. |
get_comment_class() wp-includes/comment-template.php |
Returns the classes for the comment div as an array. |
_close_comments_for_old_post() wp-includes/comment.php |
Closes comments on an old post. Hooked to comments_open and pings_open. |
wp_update_comment() wp-includes/comment.php |
Updates an existing comment in the database. |
wp_update_comment_count_now() wp-includes/comment.php |
Updates the comment count for the post. |
do_trackbacks() wp-includes/comment.php |
Performs trackbacks. |
pingback() wp-includes/comment.php |
Pings back the links found in a post. |
_WP_Editors::editor_settings() wp-includes/class-wp-editor.php |
Changelog
Version | Description |
---|---|
1.5.1 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
For reference, WP_Post OBJECT contains following fields:
Wouldn’t it be better practice to use get_the_title(..) in this case? directly accessing the post object’s data member would bypass applying filters and enforcing protected and private settings, unless that’s explicitly desired.
If you need special things—[shortcodes], paragraph tags, anything exciting—in the content, you should apply the filters as opposed to using do_shortcode().
To get the title for a post with ID 7:
Alternatively, specify the $output parameter:
If you want to get a post by slug, you could do a new WP_Query, or use the get_page_by_path function: https://developer.wordpress.org/reference/functions/get_page_by_path/
You’ll need to use the post_type if you are not getting a page.
For Reference : WP_Post Object has following properties, which are returned by get_post().
To Get author of the Post
If you have a shortcode in the content you should use:
Top ↑
Feedback
If you need the content use
post_content
:Change
1
to the post ID. — By Chiss22 —Either Al’s or Chiss’ way will work, depending on the value of second parameter. Chiss’ version does not process shortcodes. — By crstauf —