get_post_meta( int $post_id, string $key = '', bool $single = false )
Retrieve post meta field for a post.
Parameters
- $post_id
-
(int) (Required) Post ID.
- $key
-
(string) (Optional) The meta key to retrieve. By default, returns data for all keys.
Default value: ''
- $single
-
(bool) (Optional) Whether to return a single value.
Default value: false
Return
(mixed) Will be an array if $single is false. Will be value of meta data field if $single is true.
Source
File: wp-includes/post.php
function get_post_meta( $post_id, $key = '', $single = false ) {
return get_metadata('post', $post_id, $key, $single);
}
Related
Uses
Uses | Description |
---|---|
wp-includes/meta.php: get_metadata() |
Retrieve metadata for the specified object. |
Used By
Used By | Description |
---|---|
wp-includes/author-template.php: get_the_modified_author() |
Retrieve the author who last edited the current post. |
wp-includes/general-template.php: get_login_image_html() |
Return the HTML for the image on the login screen. This is either a link showing the ClassicPress logo (the default) or the site’s custom login image (if enabled). |
wp-includes/general-template.php: get_custom_logo() |
Returns a custom logo, linked to home. |
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php: WP_REST_Attachments_Controller::prepare_item_for_response() |
Prepares a single attachment output for response. |
wp-includes/media.php: wp_maybe_generate_attachment_metadata() |
Maybe attempts to generate attachment metadata, if missing. |
wp-includes/media.php: wp_prepare_attachment_for_js() |
Prepares an attachment post object for JS, where it is expected to be JSON-encoded and fit into an Attachment model. |
wp-includes/media.php: wp_enqueue_media() |
Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. |
wp-includes/media.php: wp_get_attachment_image() |
Get an HTML img element representing an image attachment |
wp-includes/class-wp-post.php: WP_Post::__get() |
Getter. |
wp-includes/nav-menu.php: wp_update_nav_menu_item() |
Save the properties of a menu item or create a new one. |
wp-includes/nav-menu.php: wp_get_nav_menu_items() |
Retrieves all menu items of a navigation menu. |
wp-includes/nav-menu.php: wp_setup_nav_menu_item() |
Decorates a menu item object with the shared navigation menu item properties. |
wp-includes/nav-menu.php: wp_get_associated_nav_menu_items() |
Get the menu items associated with a particular object. |
wp-includes/nav-menu-template.php: _wp_menu_item_classes_by_context() |
Add the class property classes for the current context, if applicable. |
wp-includes/class-wp-embed.php: WP_Embed::shortcode() |
The do_shortcode() callback function. |
wp-includes/capabilities.php: map_meta_cap() |
Map meta capabilities to primitive capabilities. |
wp-includes/user.php: WP_User_Request::__construct() |
Constructor. |
wp-includes/user.php: _wp_privacy_send_request_confirmation_notification() |
Notify the site administrator via email when a request is confirmed. |
wp-includes/user.php: _wp_privacy_send_erasure_fulfillment_notification() |
Notify the user when their erasure request is fulfilled. |
wp-includes/theme.php: get_header_image_tag() |
Create image tag markup for a custom header image. |
wp-includes/theme.php: get_uploaded_header_images() |
Get the header images uploaded for the current theme. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::add_enclosure_if_new() |
Adds an enclosure to a post if it’s new. |
wp-includes/post-thumbnail-template.php: get_post_thumbnail_id() |
Retrieve post thumbnail ID. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::_prepare_post() |
Prepares post data for return in an XML-RPC object. |
wp-includes/post-template.php: get_page_template_slug() |
Get the specific template name for a given post. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::import_theme_starter_content() |
Import theme starter content into the customized state. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::set_changeset_lock() |
Marks the changeset post as being currently edited by the current user. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::refresh_changeset_lock() |
Refreshes changeset lock with the current time if current user edited the changeset before. |
wp-includes/post.php: wp_check_for_changed_slugs() |
Check for changed slugs for published post objects and save the old slug. |
wp-includes/post.php: wp_check_for_changed_dates() |
Check for changed dates for published post objects and save the old date. |
wp-includes/post.php: wp_delete_attachment() |
Trash or delete an attachment. |
wp-includes/post.php: wp_get_attachment_metadata() |
Retrieve attachment meta field for attachment ID. |
wp-includes/post.php: wp_get_attachment_url() |
Retrieve the URL for an attachment. |
wp-includes/post.php: wp_untrash_post() |
Restore a post or page from the Trash. |
wp-includes/post.php: wp_untrash_post_comments() |
Restore comments for a post from the trash. |
wp-includes/post.php: wp_insert_post() |
Insert or update a post. |
wp-includes/post.php: get_post_custom() |
Retrieve post meta fields, based on post ID. |
wp-includes/post.php: get_post_status() |
Retrieve the post status based on the Post ID. |
wp-includes/post.php: get_attached_file() |
Retrieve attached file path based on attachment ID. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::save_nav_menus_created_posts() |
Publish the auto-draft posts that were created for nav menu items. |
wp-admin/custom-header.php: Custom_Image_Header::get_uploaded_header_images() |
Gets the previously uploaded header images. |
wp-admin/includes/misc.php: WP_Privacy_Policy_Content::text_change_check() |
Quick check if any privacy info has changed. |
wp-admin/includes/misc.php: WP_Privacy_Policy_Content::_policy_page_updated() |
Update the cached policy info when the policy page is updated. |
wp-admin/includes/misc.php: WP_Privacy_Policy_Content::get_suggested_policy_text() |
Check for updated, added or removed privacy policy information from plugins. |
wp-admin/includes/media.php: edit_form_image_editor() |
Displays the image and editor in the post editor |
wp-admin/includes/media.php: get_attachment_fields_to_edit() |
Retrieves the attachment fields to edit form fields. |
wp-admin/includes/media.php: media_upload_form_handler() |
Handles form submissions for the legacy media uploader. |
wp-admin/includes/template.php: _post_states() | |
wp-admin/includes/template.php: _media_states() | |
wp-admin/includes/image-edit.php: wp_save_image() |
Saves image to post along with enqueued changes in $_REQUEST[‘history’] |
wp-admin/includes/image-edit.php: wp_image_editor() |
Loads the WP image-editing interface. |
wp-admin/includes/image-edit.php: wp_restore_image() |
Restores the metadata for a given attachment. |
wp-admin/includes/ajax-actions.php: wp_ajax_crop_image() |
Ajax handler for cropping an image. |
wp-admin/includes/ajax-actions.php: wp_ajax_wp_fullscreen_save_post() |
Ajax handler for saving posts from the fullscreen editor. |
wp-admin/includes/ajax-actions.php: wp_ajax_save_attachment() |
Ajax handler for updating attachment attributes. |
wp-admin/includes/meta-boxes.php: post_thumbnail_meta_box() |
Display post thumbnail meta box. |
wp-admin/includes/meta-boxes.php: post_submit_meta_box() |
Displays post submit form fields. |
wp-admin/includes/file.php: wp_privacy_generate_personal_data_export_file() |
Generate the personal data export file. |
wp-admin/includes/file.php: wp_privacy_send_personal_data_export_email() |
Send an email to the user with a link to the personal data export file |
wp-admin/includes/file.php: wp_privacy_process_personal_data_export_page() |
Intercept personal data exporter page ajax responses in order to assemble the personal data export file. |
wp-admin/includes/post.php: wp_check_post_lock() |
Check to see if the post is currently being edited by another user. |
wp-admin/includes/post.php: edit_post() |
Update an existing post with values provided in $_POST. |
Changelog
Version | Description |
---|---|
WP-1.5.0 | Introduced. |